user428602
user428602

Reputation: 57

How to iterate through a paginated jQuery datatable

I have a datatable where in I have set 100 rows to a page. Anyway, with jQuery -sending request to server etc., I have the data filled, for e.g. say one of the calls brings in 260 rows. Later when I have to perform some checks for each row for e.g. to see if some values have been selected or something like that, I need to iterate. So when I use fnGetNodes() or fnGetData() both seem to get only the first 100 rows of the table that is the 1st page rows. I want to be able to iterate all the 260 rows, because the user may have paged back and forth and made several selections/changes to the data. Any help is appreciated. I am using jQuery 1.4 version of DataTable.

Upvotes: 1

Views: 1538

Answers (1)

jramoyo
jramoyo

Reputation: 11

Not ideal, but what we do is to temporarily expand the datatable so that all rows are shown, iterate, then revert back to the original length.

var origLength = dataTable.fnLengthChange();
dataTable.fnLengthChange( dataTable.fnPagingInfo().iTotal );
// Iterate here
dataTable.fnLengthChange( origLength );

Hope there's a more decent solution.

Upvotes: 1

Related Questions