I'm using an amazing JavaScript UI library: w2ui. I'm learning how the widget Grid works.
Each row of the Grid is identified using a unique integer ID (recid). If your database has an integer as primary key this is perfect, you can use this key like recid. But my database table has a composite primary key, a combination of 4 columns.
First I thought of a solution: use a hash function to generate an integer value using the 4 column values:
hash(idA, idB, idC, idD) = recid
An example of JSON returned by the server:
records: [
{
"recid": 565587,
"key": {
"idA": "01",
"idB": "01",
"idC": "1981",
"idD": "111"
},
"value": 1000
}
]
The recid is calculated at server side and used at client side to identify the grid record.
But it still isn't a solution, because when I change a cell value of the grid (I'm using inline editing), the widget only sends to the server the changed value and the recid, but not the composite key. So I can't identify the database table row to make the update.
Someone has a solution?
Maybe a configuration to force to send the key object to the server?