Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
450
How to work with primary key as composite primary key in igGrid
posted

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?

Parents
  • 29417
    Verified Answer
    Offline posted

    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

Reply Children