I have a (legacy) table with a composite key:
@Embeddable
public class BrokerMailerCompKey extends EmbeddableEntity {
private static final long serialVersionUID = 1084369018502935425L;
@Column(name = "brk_id")
private Long brkId;
@Column(name = "cus_id")
private Long cusId;
<rest omitted>
public class BrokerMailer extends BaseGenericIdEntity<BrokerMailerCompKey> {
private static final long serialVersionUID = -2619395226798110431L;
@EmbeddedId
private BrokerMailerCompKey id;
<rest omitted>
Here is a simple DataTable display:
this.dataCollection = collection<BrokerMailer>(BrokerMailer.NAME, {
view: "_local",
sort: "+customername",
filter: {
conditions: [
{property: "broker", operator: "=", value: brokerId}
]
},
});
}
render() {
if (!this.dataCollection) return null;
return (
<div>
<DataTable
dataCollection={this.dataCollection}
canSelectRowByClick={true}
tableProps={{bordered: true}}
columnDefinitions={[
{field: "customername", columnProps: {title: "Mailer"}}
]}
/>
</div>
);
}
handleRowSelectionChange = (selectedRowKeys: string[]) => {
**<<<What do I actually get for selectedRowKeys and how do they get passed as parameters?>>>**
};
}
When I display the data in a table and click on a row, it appears I get an Object as the selectedRowKey, which I guess you would expect since it is a BrokerMailerCompKey. The generated code expects a string[] array, however. React “entityId” in the path is only a string, so what gets passed when I click on a row?
Worse yet, I’m getting a React warning in the console. So it appears the key for each table row is an Object and React can’t see what’s inside it, so it can’t tell that the keys are actually different?
What’s the correct way to handle a DataTable with an embedded composite key?
Warning: Encountered two children with the same key,
[object Object]
. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.