is this serverside ?

is this serverside ?

SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0
edited February 2017 in Priority support

Hi Support,

Please let me know below statements are server side or not.

var table=$(\'#viewleadtable\').dataTable({
"responsive": true,
"processing": false,
"aaSorting": [ [0,\'desc\'], [1,\'asc\'] ],
"sAjaxSource": url,
"columns": [
{ data: \'enqno\' } ,
....

I have 1094 records in Table and Record populate in Table is very very slow.

Regards.
Sunil

Answers

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    The serverSide option is the one that is used to enable server-side processing, so no, the above code does not utilise server-side processing.

    How long does the server take to load the JSON data? Your browser's "Network" panel will give you this information.

    Allan

  • SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0
    edited February 2017

    Hi Allan,
    I had added the following

    Processing : true,
    serverSide : true,

    if i add this then pagination do not come and show entire table data without pagination.

    I had also checked and found it is taking

    Waiting 253 ms
    Receiving 883 ms for 344 records.

    Regards.
    Sunil

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    HI Sunil,

    if i add this then pagination do not come and show entire table data without pagination.

    It sounds like the server isn't implementing server-side processing in that case. The first thing I would suggest is that you use ajax rather than the legacy sAjaxSource option. That will make sure that the modern parameters are sent to the server rather than the legacy.

    Can you show me your server-side script please?

    Allan

  • SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0

    Hi Allan,
    Find below my serverSide scripting.

    $sql="select * from crm_leads a,crm_rep_master b"
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_assoc($result)) {
    $data[] = $row;
    }
    //

    $results = array(
            "sEcho" => 1,
        "iTotalRecords" => count($data),
        "iTotalDisplayRecords" => count($data),
          "aaData"=>$data);
    

    echo json_encode($results);
    mysql_close();

    Regards.
    Sunil

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    That's not server-side processing though. There is no code there to do paging (LIMIT), filtering (WHERE) or sorting (ORDER BY).

    That's just getting the full data set from the database table and sending it to the client. It is the client that is then doing the processing (i.e. sorting, filtering and paging).

    This page fully documents the parameters sent to the server and those that are expected back by the client in order to correctly implement server-side processing.

    If this is one of your Editor tables, the Editor PHP libraries have server-side processing support built in.

    Allan

  • SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0

    Hi Allan,
    Thanks for Update.
    As per you suggestions and example, i will change my code accordingly. I have one question ,

    here i am adding new row with data dynamically , how this will reflect when i will be using serverSide Processing.

    Regards.
    Sunil

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    When you are adding a new row with Editor (which is what I presume you mean by adding a new row with data dynamically?), the table will automatically redraw when the new row has been added (with an Ajax call to the server).

    You can see that happening in practice with the link I gave above.

    Regards,
    Allan

  • SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0

    Hi Allan,

    No i will not use editor to insert new row rather i will use table.row.add after success received from ajax response.

    I hope i am able to explain clearly .

    Regards.
    Sunil

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    Hi Sunil,

    The row.add() method is basically useless if you are using server-side processing. Any draw of the table will make an Ajax request to the server to get the data to be displayed (that's the whole point of server-side processing). row.add() is client-side only and thus not appropriate for use with server-side processing.

    Allan

  • SunilgoelSunilgoel Posts: 48Questions: 19Answers: 0

    Hi Allan,

    i understand row.add() is client side, Now i will give you an example

    I am using server side processing
    i am on page no say 5
    i have given NewRow button in Table header and user click and add row [ using bootstrap modal ]
    and programatically newly inserted row show on current page ( Page 5 in my case ) using row.add.
    i don't now due to order by (desc) behaviour in DataTable , DataTable will be refresh automatically and set table on Page No 1 or insert in current page ( page No 5) without doing anything.
    i guess, draw triggered manually not automatic.

    Regards.
    Sunil

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin

    Hi Sunil,

    You can use draw( false ) (i.e. pass false as the parameter to draw()) to have it not change the page. However if you have server-side processing enabled it will still make an Ajax request to the server to get the latest information and redraw the current page.

    The result is that if you have added a row on the client-side (using row.add()) it will be immediately removed. As I say, row.add() is not suitable for use with server-side processing.

    If you want to add a new row, you have to add it at the data source (in the case of server-side processing, that is at the server-side - typically a database table).

    Does that clarify things a bit?

    Allan

This discussion has been closed.