delete rows based on the id
delete rows based on the id
obet.tea46
Posts: 6Questions: 0Answers: 0
i want to delete rows based on the id in select multiple option.
example:
in select multiple option i have value or id: a1,b2,c3, and d4.
after select b2 and b3 in select multiple option then i hit a remove button,
row b2 and c3 in dataTables removed.
please help..
thanks for the answer.
example:
in select multiple option i have value or id: a1,b2,c3, and d4.
after select b2 and b3 in select multiple option then i hit a remove button,
row b2 and c3 in dataTables removed.
please help..
thanks for the answer.
This discussion has been closed.
Replies
i'm hoping allan knows about this...
still awaiting for response..
[code]
oTable.fnDeleteRow( document.getElementById( 'a1' ) );
[/code]
( http://datatables.net/api#fnDeleteRow )
This assumes that the row is in the visible table. If not you could use a slightly slower method:
[code]
oTable.fnDeleteRow( $('#a1', oTable.fnGetNodes()) );
[/code]
Allan
Thanks for the reply..I have a concern though...
when I am using oTable.fnGetNodes() and I'm passing in a String with value "my string"
and when I am showing it in alert(sData), I am only getting "my"..
is this a bug? I want to use my own implementation of delete on the server side that's why I am checking on this fnGetNodes().
i use the alternate way, i change the select multiple option id to increment number.
cause your dataTable doesn't use index to delete rows, but using the increment number. is it true?
anyway thank you very much for the reply..
>> when I am using oTable.fnGetNodes() and I'm passing in a String with value "my string"
fnGetNodes will take only one (optional) parameter - which must be an integer, not a string - http://datatables.net/api#fGetNodes - so I'm not quite sure what you mean here. Are you using server-side processing? If so the way to delete a row, is to not do any DataTables stuff until you've actually deleted the row from the database! So the 'delete' action is actually to send an XHR to the server to delete the row and then refresh the table (using fnDraw) based on the new data on the server.
@obet.tea46:
DataTables has an internal array called aoData which is uses to store information about each row. This is the 'index' that I tend to refer to in DataTables, and what fnGetPosition will give you. It's also what fnDeleteRow etc deal with (since the ordering can be changed by the end user). With v1.6 this has been made a lot easier as you can pass in TR elements and DataTables will calculate the index to use itself. Hope this explains it!
Regards,
Allan
thankssss a lot ..^_^
I need to delete a row from a table by its ID. I have tired both examples shown above, and neither are working. As an example:
[code]
var oldRow = document.getElementById('rowId');
$('#curClasses').dataTable().fnDeleteRow(oldRow);
[/code]
In the browser, the script simply stops. Firebug is returning the error "a is null" in jquery.dataTables.min.js. If I print the value of oldRow to the screen, it is properly returning [object HTMLTableRowElement].
Any help will be appreciated.
[code]
var table = $('#curClasses').dataTable();
table.fnDeleteRow( table.$('#rowId')[0] );
[/code]
Allan