2

I'm using JQuery datatable to display all projects existing in my database:

<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('table.display').dataTable({
            "bJQueryUI": true,
             "sPaginationType": "two_button",
             "aaSorting":[[2, "desc"]],
             "bRetrieve": true,
              "iDisplayLength": 10, // 10 records will be displayed by default
              "sScrollY": "250px",
              "sDom": '<"H"Tfr>t<"F"ip>',
              "oTableTools": {
                  "sRowSelect": "multi",
                  "aButtons": [
                      "copy", 
                      {
                          "sExtends": "csv",
                          "sTitle": "data"
                      }                     
                  ]
               }
        });
    })
</script>

If there are more than 10 records, it will be possible to move to the next 10 records using a button.

The problem is that one of my colleagues told me that this could make the page very slow in case we have a huge number of projects. I'm not sure with this because if I choose to display 10 records, then it won't make the page slow. Am I right ?

Bests

0

2 Answers 2

1

If there are more than 10 records, it will be possible to move to the next 10 records using a button? Yes, absolutly.

Datatables work in 2 ways:

  1. Client side, it means all data will completely downloaded and paged ( automatically by datatable, ex: 10 records per page ). This way,page will be slow if you have huge amount of data
  2. Server side, this way datatable only downloaded requested data, so it will request to server each time next / previous page. This way you must have server side code to paging data manually ( of course it must be compatible with request from datatable ).
2
  • This is very informative, but according to you, my colleague was right! What do you suggest @Somy A ?
    – Anibel
    Oct 7, 2013 at 10:06
  • It depends on your needs, in case you have huge data (maybe thousands row data) , i prefer server-side processing. MySQL or other Database engine have more advanced & efficient in sorting & limiting record technique. But in case you only have limited data ( hundreds ), i thinks it's enough using client side processing, in this case you don't need to code server-side processing. refer this page on server-side processing: datatables.net/examples/data_sources/server_side.html
    – Somy A
    Oct 7, 2013 at 13:18
1

Please have a look at here.

If you want to have server-side processing click here.

There are many ways to get your data into DataTables, and if you are working with seriously large databases, you might want to consider using the server-side options that DataTables provides. Basically all of the paging, filtering, sorting etc that DataTables does can be handed off to a server (or any other data source - Google Gears or Adobe Air for example!) and DataTables is just an events and display module.

$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "../examples_support/server_processing.php"
    } );
} );
1
  • While these links may answer the question, you should avoid link-only answers.
    – pinckerman
    Nov 28, 2013 at 13:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.