In my grid, created with slick grid I am trying to create grid row .It is possible to get a unique ID only after saving these row data to the back-end database. How can I handle this situation? Without unique id, the cell data is not retained there when I move to next cell
Asked
Active
Viewed 294 times
2 Answers
0
I would do this method:
- Create a temporary unique_id for the new row data.
- Post the row data to back-end database and return the id generated on callback.
- Update the row data with the returned id that was generated.

winghei
- 632
- 4
- 9
0
An alternative and probably faster (in terms of saving a network round trip) solution is that you generate a GUID/UUID on client side. To back off generating GUID with example JavaScript code, check out this great SO answer.
Quote about the collision probability when generating GUID:
For example, with 3.26x1015 version 4 RFC4122 UUIDs you have a 1-in-a-million chance of collision.
And the quoted code you can generate a GUID with:
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
results in:
"3bce4931-6c75-41ab-afe0-2ec108a30860"
So the actual steps of execution I propose are:
- Generate your cell data
- Generate the GUID
Voila, you have your unique ID and can move the next cell, row, etc.