Row Count
Row Count

is there a was to update the row count on a datatable? i was using the .remove() to take off rows and also used fnDeleteRow();
This question has an accepted answers - jump to answer
This discussion has been closed.
is there a was to update the row count on a datatable? i was using the .remove() to take off rows and also used fnDeleteRow();
This question has an accepted answers - jump to answer
Answers
You need to use the DataTables API (see the FAQs) rather than DOM or jQuery methods to manipulate the table's content, otherwise DataTables doesn't know that things have changed.
row().remove()
or the legacy fnDeleteRow method should do it.If not, then please link to a test case showing the issue.
Allan
so im not 100% sure how to delete a specific row but this is what I am using
var oTable = $('#tbRAP').dataTable();
oTable.fnDeleteRow(0);
we are on version 1.94
so im not sure what I was doing wrong but it does remove the row and update now, so how would I specify what row I am wanting to delete, it looks like I should be using DT_RowId. Right now I am looping through the rows using jquery, and if a successful save is made I am removing that row, so this is my table
(I but some collumns out for brevity. so here is the code I am using to loop through, which I am guessing is the issue, I am guessing I don't have access to that id?
var table = $(".StrategyReview");
var i = 0;
var k = 0;
var rowCount = $(".StrategyReview").attr('rows').length;
table.find('tr').each(function () {
if (i >= 1 && i != rowCount - k) {
I would suggesting using 1.10.x - 1.9 is no longer supported. For 1.10 you use
row().remove()
and just pass in the row node you want to remove.Allan
unfortunately moving up is not option right now
You should be able to pass the node into fnDeleteRow I think rather than an index.
Allan
so If I call oTable.fnDeleteRow(tr); it does delete a row, not the one expected and it seems count doesn't update. Thanks for all the help on this, I think I might just rebuild the table until we can update the version we are using