Hi Infragistics Team,
I have a table wherein there are three columns –
1.Sequence Number,
2.Employee ID
3.Employee Type.
Primary Key for this table is combination of Sequence Number and Employee ID.
But in igGrid, we can mention only one column name like primaryKey: "SequenceNumber".
In order to perform Insert, update, delete operation on this grid, we need to give two column values as a primary key.
We are not able to perform insert, update, delete operations on this grid.
How do we use two columns as primary key in infragistics/ignite grid?
Hello Tapas,
Thank you for posting in our forum.
Unfortunately currently the igGrid does not support setting multiple primary key columns. However you can define an unbound column, whose value can be a combination of your 3 actual primary key columns.
In that way when a record value is updated the primary key will contain all 3 necessary values, which you can then process on your server to update your actual database.
You can specify the column as unbound and set a formula for it that will populate its value with the 3 other primary key column values:
{
key: "CompositeKey", dataType: "string", unbound: true,
formula: function CombineKeys(data, grid) { return data["Key1"] + “_” + data["Key2"]+ “_” + data["Key3"]; }
}
And set the primary key to this new column:
primaryKey: “CompositeKey”
You can refer to the documentation for more information on unbound columns: https://www.igniteui.com/help/iggrid-unboundcolumns-overview
Let me know if that would solve your issue.
Regards,
Maya Kirova
Thank you so much Maya. It worked and we are able to use composite primary key in the grid
Hello Tapas , how did you actually used it , can u please share that piece of code
I am glad you were able to resolve your issue! Please, let us know if you need any additional help with your project!
Best regards,
Stamen Stoychev