FYI: Deleting rows on filtered data.
FYI: Deleting rows on filtered data.
I use an ajax call outside of DT to delete rows from my table. Everything worked out until I tried to delete a row that was hidden by filtering. I had tried this:
[code]oTable.fnGetPosition(document.getElementById(id));[/code]
and this:
[code]oTable.fnGetPosition($("#" + id)[0]);[/code]
Until I saw allan mention this method:
[code]oTable.fnGetPosition($(oTable.fnGetNodes()).filter('#'+id)[0]);[/code]
That worked all the time and for all variations(filtered, hidden, etc..) and the output is passed to oTable.fnDeleteRow of course.
I did find that if you pass null (i.e. the selector doesn't match, or element not found) it causes fnGetPosition to die (at least in chrome). So I check for that before calling it. I just didn't include that for brevity. Just thought this might help some folks. If there is better/fast/efficient way please let me know.
[code]oTable.fnGetPosition(document.getElementById(id));[/code]
and this:
[code]oTable.fnGetPosition($("#" + id)[0]);[/code]
Until I saw allan mention this method:
[code]oTable.fnGetPosition($(oTable.fnGetNodes()).filter('#'+id)[0]);[/code]
That worked all the time and for all variations(filtered, hidden, etc..) and the output is passed to oTable.fnDeleteRow of course.
I did find that if you pass null (i.e. the selector doesn't match, or element not found) it causes fnGetPosition to die (at least in chrome). So I check for that before calling it. I just didn't include that for brevity. Just thought this might help some folks. If there is better/fast/efficient way please let me know.
This discussion has been closed.
Replies
Allan