0

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?

spenibus
  • 4,339
  • 11
  • 26
  • 35
Jesús
  • 21
  • 4

1 Answers1

0

From the documentation:

Save will submit changed records. However, you can overwrite onSave event and submit whatever you want with it. You can either (1) add it to grid.postData object or (2) submit it yourself with $.ajax()

Looks like you have to override the default behavior to do what you want.

JRD
  • 1,957
  • 1
  • 12
  • 17