Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:15:21+00:00 2026-06-10T20:15:21+00:00

Why the number of rows in jquery datatable (see the code below) is not

  • 0

Why the number of rows in jquery datatable (see the code below) is not set to 5? It is equal to 10 8as by default). Why 'iDisplayLength': 5 does not work here?

<script>
function loadData() {
    $.getJSON(
              'modules/getData.php',
        function(data) {
                  var oTable = $('#newspaper-b').dataTable({
                        "sPaginationType":"full_numbers",
                        "aaSorting":[[3, "asc"]],
                        "bJQueryUI":true,
                        'iDisplayLength': 5,
                        'bLengthChange': false
                  });

                  oTable.fnDraw();

                  var list = data.flights;
                  var textToInsert = '';

                  for (var i = 0; i < list.length; i++) {
                        aux = list[i];
                        textToInsert  += '<tr><td>';
                        textToInsert  += aux.Var1;                                                                  
                        textToInsert  += '</td> </tr>' ;

                    }
                  $('table#newspaper-b tbody').html(textToInsert);

              }
    );             
}         

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:15:22+00:00Added an answer on June 10, 2026 at 8:15 pm

    Try something like this. DataTables has built-in options that let you pull data from an AJAX source without trying to build it yourself. Read the documentation and customize it as needed:

    function loadData() {
        var oTable = $('#newspaper-b').dataTable({
                "sAjaxSource": 'modules/getData.php',
                "sPaginationType": "full_numbers",
                "aaSorting": [
                    [3, "asc"]
                ],
                "bJQueryUI": true,
                'iDisplayLength': 5,
                'bLengthChange': false
        });
    };
    

    To modify the table in some way after the data is loaded, you’ll want to add the fnDrawCallback option:

     "fnDrawCallback": function( oSettings ) {
          // use jQuery to alter the content of certain cells
          $lastcell = $('#newspaper-b').find('tr').find('td:last');
          // manipulate it somehow
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to change the number of rows in the textarea using jQuery
I am trying to count the number of rows whose date has not yet
I'm trying to move X number of rows down in a table using jQuery...
I've got a table with a large number of rows that is not suitable
I want to count the number of rows in my table that are not
I need to create a jQuery datatable, in which some rows might have gray
I have a form where users can create unlimited number of rows (using jquery-
I want to know number of rows that will be affected by UPDATE query
I am trying to number some rows on a bridge table with a single
Am trying to calculate the number of rows in a table depending on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.