fnUpdate alternative?
fnUpdate alternative?
Hi,
I have a table column which contains multiple editable elements,
eg several jeditable inplace-edits with anchors, drop down select option
and checkboxes.
The cell is intially filled via a json request (in fact the whole table, via aaData),
after which bindings are applied to all the elements.
Now in order to maintain sortability, I have to call fnUpdate - and need to replace
the entire cell contents. This nukes all the bindings which then need to be re-applied.
If I update the cell using jquery selector, the bindings remain, but the data tables
internals do not get updated and sorting is broken.
Is there not a more convenient method that does not break the bindings?
Perhaps I can update a value in the data tables internal struct and call fnDraw after?
cheers,
S
I have a table column which contains multiple editable elements,
eg several jeditable inplace-edits with anchors, drop down select option
and checkboxes.
The cell is intially filled via a json request (in fact the whole table, via aaData),
after which bindings are applied to all the elements.
Now in order to maintain sortability, I have to call fnUpdate - and need to replace
the entire cell contents. This nukes all the bindings which then need to be re-applied.
If I update the cell using jquery selector, the bindings remain, but the data tables
internals do not get updated and sorting is broken.
Is there not a more convenient method that does not break the bindings?
Perhaps I can update a value in the data tables internal struct and call fnDraw after?
cheers,
S
This discussion has been closed.
Replies
[code]
$(oSettings.aoData[ aPos[0] ].nTr).find('td:eq(5) a').html( 'Some String' )
oTable.dnDraw()
[/code]
This code updates the data without breaking bindings, but still sorting is broken ;(
Allan
This code is from the jeditable 'callback' callback. jeditable has already updated the html
in the DOM, so here we just need to update the _aData array. This is refers to the simpler
case where a table cell contains an html anchor (possibly with attributes), and the anchor
contains the editable text. 'this' refers to the anchor in th callback. sValue is the modified
string (passed into the callback by jeditable).
[code]
var aPos = oTable.fnGetPosition( $(this).parents('td').get(0) )
// Extract the current html string, update with the help of jQuery, set the result in _aData array:
var html_str = oSettings.aoData[ aPos[0] ]._aData[ aPos[1]+1 ]
oSettings.aoData[ aPos[0] ]._aData[ aPos[1]+1 ] = $( html_str ).html( sValue ).get(0).outerHTML
oTable.fnDraw()
[/code]