Multi header grid - pk on cell?
Multi header grid - pk on cell?
jorgelaranjo
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
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
You would need to include hidden fields (
hidden
) which are set to thepk
value - e.g.flows.0.pk
.Allan
Would I still need the
editor.on
logic to set it from thetd attributes
previously set usingcreatedCell
or can it be mapped directly from the object list and thus automatically captured at submission?Editor will treat that sort of structure as objects, so it should be automatic.
Allan