getting the record ID in editable callback
getting the record ID in editable callback
Hi, I'm using DataTables with a javascript array as a data source. Each of my database records has a unique ID, but I don't want that ID to be a visible column in the table. However, I *do* want that ID when I'm in jQuery or jeditable callbacks for those table cells.
The example at api/editable.html does this with an id attribute on the tr nodes, which is great, except those are hardcoded in to the HTML source and rows added from the javascript API don't get those attributes.
At the moment, the best approach I see is to keep the ID in a column, and tell datatables to keep it "visible" so it gets put in the DOM, but then apply a CSS class to hide it, e.g.
[code]
aaData[i] = [r.id, r.name /* , ... */ ]
aoColumns = [{sClass: 'recordID hide', bSearchable: false} /* , ... */ ]
[/code]
but that feels a little kludgy.
The cleanest solution I can think of is to put the row array somewhere in jQuery(nTr).data(), although storing the row index instead of the row array might work too.
The example at api/editable.html does this with an id attribute on the tr nodes, which is great, except those are hardcoded in to the HTML source and rows added from the javascript API don't get those attributes.
At the moment, the best approach I see is to keep the ID in a column, and tell datatables to keep it "visible" so it gets put in the DOM, but then apply a CSS class to hide it, e.g.
[code]
aaData[i] = [r.id, r.name /* , ... */ ]
aoColumns = [{sClass: 'recordID hide', bSearchable: false} /* , ... */ ]
[/code]
but that feels a little kludgy.
The cleanest solution I can think of is to put the row array somewhere in jQuery(nTr).data(), although storing the row index instead of the row array might work too.
This discussion has been closed.
Replies
also relevant is http://stackoverflow.com/questions/2384102/jquery-datatables-how-to-get-column-id