Multi header grid - pk on cell?

Multi header grid - pk on cell?

jorgelaranjojorgelaranjo Posts: 5Questions: 2Answers: 0

I have the following JSON being sent to Datatables Editor

{
  "data": [
    { 
      "description": "ROW1 HEADER", 
      "flows": [
        {
          "amount": "10", 
          "pk": "pk1"
        }, 
        {
          "amount": "11", 
          "pk": "pk2"
      }, 
    {
      "description": "ROW2 HEADER", 
      "flows": [
        {
          "amount": "10", 
          "pk": "pk3"
        }, 
        {
          "amount": "11", 
          "pk": "pk4"
        }
]
}

I can get the amount to the table using:

columns: [
                {data: 'DT_RowId'},
                {data: 'description'},
                {data: 'flows.0.amount'},
                {data: 'flows.1.amount'},

However with the inline editor I get the, after editing to amount 100:

data[12][flows][0][amount]: 100
action: edit

I can parse the data[12]... but I'd like to get the primary key of this cell as it would make the update a lot easier.

Is it possible?
Backend is in Python/Flask

Answers

  • jorgelaranjojorgelaranjo Posts: 5Questions: 2Answers: 0
    edited March 8

    Seems to be more or less this but not exactly as not sure how the createRow would be used to inject the attribute to the <td> element.

    https://datatables.net/forums/discussion/60332/using-editor-where-each-cell-has-its-own-primary-key

  • allanallan Posts: 57,265Questions: 1Answers: 9,121 Site admin

    You would need to include hidden fields (hidden) which are set to the pk value - e.g. flows.0.pk.

    Allan

  • jorgelaranjojorgelaranjo Posts: 5Questions: 2Answers: 0

    Would I still need the editor.on logic to set it from the td attributes previously set using createdCell or can it be mapped directly from the object list and thus automatically captured at submission?

  • allanallan Posts: 57,265Questions: 1Answers: 9,121 Site admin

    Editor will treat that sort of structure as objects, so it should be automatic.

    Allan

Sign In or Register to comment.