4

I'm working on a travel portal and using DataTables JS Plugin To Populate results.

"search.results" is an array of JSON objects each containing search results, However, only first 30 are getting populated and the rest don't.

console does not log any errors and all search objects appear when logged in console from within the "for" loop.

I need all the results to be populated in the table.

Kindly Help, Thanks in advance.

**datatable declaration**

 var oTable = $('#search').DataTable({
"bDestroy": true,
"aaSorting": [[4, 'asc']],
"bPaginate": true,
"bInfo": false,
"bFilter": true,
"bScrollCollapse": true,
"fnInitComplete": function() {
    this.fnAdjustColumnSizing(true);
}
});

**results population**

for(var j=0; j<search.results.length; j++){
oTable.row.add([
search.results[j].airline,
search.results[j].from,
search.results[j].to,
search.results[j].duration,
search.results[j].fare,
'<button id="button-'+j+'" class="btn btn-change1 book_btn"  type="button">book</button>',
]).draw();
};
3
  • this is the actuall code : pastebin.com/1G1u7Wzk Commented Aug 8, 2014 at 12:34
  • 2
    I've created a JSFiddle which emulates what you're trying to do. It works ok for me. Commented Aug 8, 2014 at 15:00
  • Can you provide the HTML, and search.results? Commented Aug 27, 2014 at 18:26

1 Answer 1

1

You are using search.results.length in your for loop and search result is limited to 30 in your paginate (due to "bPaginate": true) Try to override default limit in your query or just set bPaginate to false

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.