Primary Key Column Edit

Is it possible to Edit Primary Key Column once it has been saved ? Currently, I have auto populated column set for Primary key.  once it has been saved.  It's disabled. and not goes into edit mode. But If i make isPrimaryKey=false then it makes it editable. in this case it is not able to retain change values when clicked on update button in toolbar.


6 Replies 1 reply marked as answer

PS Pavithra Subramaniyam Syncfusion Team May 11, 2022 02:06 PM UTC

Hi PDev,


Thanks for contacting Syncfusion support.


In the EJ2 Grid component, our CRUD operations and some other features are depending on the Primary key value. So, It is not suggestible to modify the already saved Primary Key value of the column.


Regards,

Pavithra S



PD PDev May 12, 2022 07:03 AM UTC

I have 2 queries 

  1. Is there other way to do it ? 
  2. If it is primary key then it should nto allow duplicate values to be enter. But currently, it allows me to enter duplicates values, in my case UserName which is auto complete



PS Pavithra Subramaniyam Syncfusion Team May 13, 2022 03:59 PM UTC

Hi PDev,


We don’t have any support to modify the already saved Primary Key in our EJ2 Grid component since the record tracking for the update, and delete actions will be done based on the Primary key value only. So changing this value will break the default behavior of the Grid Crud action.


Regards,

Pavithra S



PD PDev May 28, 2022 06:08 AM UTC

Okay, so What i did is. I have added a new Column. and keeping that as Primary Key so I can edit other columns. however while using Toolbar Add button I need to have some integer number as Primary Key value in column. For which I have used "defaultValue" in which I am populating unix timestamp. now, If i add new rows multiple time. It does not change the timestamp and keeps the same value.  which is not serving the purpose. Now, I need to have some Auto Incremental value in the column. For which I enabled "isIdentity" property in column as well. 


Can you please setup some example. which will have simple ID column with Auto Increment when clicked on Toolbar "Add" button



PD PDev May 28, 2022 11:51 AM UTC

Figured it out. Added a "BeforeBatchAdd" event. and changed the Primary Key value before that event occurs. it worked and now i have unique values every time user adds a new row. so far everything is working okay.


Marked as answer

PS Pavithra Subramaniyam Syncfusion Team May 30, 2022 08:02 AM UTC

Hi PDev,


We are glad to hear that you have managed to achieve your requirement.


Please get back to us if you need further assistance.


Regards,

Pavithra S


Loader.
Up arrow icon