Deleting multiple rows across pages

Deleting multiple rows across pages

saudagarrizwansaudagarrizwan Posts: 8Questions: 1Answers: 0
edited February 2014 in DataTables 1.10
Hi,
I have a datatable with paging. Table contains checkboxes on each row. I have only one delete button on top of the table. If user checks the check boxes and clicks on delete the rows will get deleted.
I have an issue here. If user selects few rows in first page, few in second and few in 3rd and click on delete, (suppose now user in 3rd page) rows getting deleted are from only 3rd page. 1st and 2nd are not getting deleted.
Below is the code am using.
[code]
for(var a = 0; a < aID.length; a++) {
var id = '#tr_' + aID[a];
oTable.fnDeleteRow(oTable.fnGetPosition($(id).get(0)));
}
[/code]
Here aID is the array of values of the rows and id is tr id.

Appreciate your help.

Replies

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Use the $ API method to query over all rows, not just the current page: http://datatables.net/docs/DataTables/1.9.4/#$

    Allan
  • saudagarrizwansaudagarrizwan Posts: 8Questions: 1Answers: 0
    Hi Allan,
    Thank you. But my [quote]aID[/quote] contains all the rows from all the pages. The thing is am not able to delete this by fnGetPoistion.
  • saudagarrizwansaudagarrizwan Posts: 8Questions: 1Answers: 0
    Hi Allan,
    Am able to delete these by keeping the index. But if I select rows using check box and delete. Row is deleting but the above row is getting checked. Am not sure why it is showing as checked.
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Can you please link me to the page showing the error so I can take a look.

    Allan
This discussion has been closed.