client side pagination with server side data response in jason

client side pagination with server side data response in jason

kamalpreetkamalpreet Posts: 2Questions: 2Answers: 0

Hi I am fetching some records from server side keeping bserverside=true but I want it to be displayed 20 records per page on client side . Please tell me how to do it?

Answers

  • PrateekPrateek Posts: 1Questions: 0Answers: 0
    edited June 2015

    You can specify the "pageLength" parameter to tell datatable, the number of records you want to display per page.

    For more info. check : https://datatables.net/reference/option/pageLength

    If you are using datatable version 1.9 than refer this : http://legacy.datatables.net/ref#iDisplayLength

  • kamalpreetkamalpreet Posts: 2Questions: 2Answers: 0

    Hi I have this code working:

    $('#tablename').dataTable({
    "destroy" : true,
    "bServerSide": true,
    "sAjaxSource": "abc.do?method=search&&lastName=" + lastName + "&firstName=" + firstName,
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bJQueryUI": true,
    "oLanguage": { "sEmptyTable": "No records to display"},
    "iDisplayLength": 20,
    "aoColumnDefs": [

                                 {"aTargets": [0, 2], "bsearchable": false },
                                 {"aTargets": [2], "bVisible": false } ,           
                                 {
                                       "aTargets": [ 0 ], 
                                       "mRender": function ( data, type, full ) {
    return '<a href="javascript:returnInfo(\''+data+'\',\''+full[2]+'\')" id="link"> '+ data +' </a>';
                                        }
                                  },
                                  {
                                       "aTargets": [ 1 ],
                                       "mRender": function(data, type, full) {
                                            return (data) ? data  : "N/A" ;
                                        }
                                  }]
    
            }); 
        }
    

    Her I am fetching data from server side by ajax request but I want that search from default search box should be in client side filtering and pagination also in client side only..how can I achieve it? Do you know how to do that.

  • kamalpreetkamalpreet Posts: 2Questions: 2Answers: 0

    Hi I have this code working:

    $('#tablename').dataTable({
    "destroy" : true,
    "bServerSide": true,
    "sAjaxSource": "abc.do?method=search&&lastName=" + lastName + "&firstName=" + firstName,
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bJQueryUI": true,
    "oLanguage": { "sEmptyTable": "No records to display"},
    "iDisplayLength": 20,
    "aoColumnDefs": [

                                 {"aTargets": [0, 2], "bsearchable": false },
                                 {"aTargets": [2], "bVisible": false } ,           
                                 {
                                       "aTargets": [ 0 ], 
                                       "mRender": function ( data, type, full ) {
    return '<a href="javascript:returnInfo(\''+data+'\',\''+full[2]+'\')" id="link"> '+ data +' </a>';
                                        }
                                  },
                                  {
                                       "aTargets": [ 1 ],
                                       "mRender": function(data, type, full) {
                                            return (data) ? data  : "N/A" ;
                                        }
                                  }]
    
            }); 
        }
    

    Her I am fetching data from server side by ajax request but I want that search from default search box should be in client side filtering and pagination also in client side only..how can I achieve it? Do you know how to do that.

This discussion has been closed.