Data table -server side processing

Data table -server side processing

kpandakpanda Posts: 3Questions: 1Answers: 0

I am using Data table's Server side processing feature to process a huge set of data - load around 10000 records. I have done as per the example . But I am struggling with the server side logic.how do I dynamically send parameters to server side , to fetch the data. i see the parameter options, but I dont understand how to use them.Is there any example available how to send the parameters dynamically. e.g If I am clicking on Page 4 , how do I tell the server to fetch records from 40 to 50

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    I have done as per the example.

    The example works correctly, so you must have done something different.
    Page 4 should show records 31-40.

    Also, 10000 records is not a "huge" set of data for DataTables.

  • allanallan Posts: 64,020Questions: 1Answers: 10,555 Site admin

    how do I dynamically send parameters to server side

    If you want to send customer parameters use ajax.data.

    I dont understand how to use them

    See the documentation. If there is a particular part you would like to be explained, please say.

    Allan

  • kpandakpanda Posts: 3Questions: 1Answers: 0
    edited April 2015

    Hi Please check the below code. I am using Data Table1.8 version. now when I click on each page , a request goes to the server . what i am not understanding is when I click on page 2 , how do i send the record number to the server . currently in each fetch i am getting the same set of records. If I have 10000 records, should my query only return 10 records based on the page number or my query should return 10000 records, but data table will only show 10 records?

    $('#feReportList').dataTable({
                    "bProcessing": true,
                    "sAjaxSource": "FEList1.action?categoryId=" + categId+ "&feTypeId=" + feTypeId;,
                    "sAjaxDataProp": "feDataList",
                    "aoColumns": [{ "mData": ""  },
                                  { "mData": "FE Id",
                                            "fnRender": function(obj) {
                                                var sReturn = "FEDetailDummy.action?categoryName="+ categName + "&categoryId=" + categId + "&feTypeId=" + feTypeId + "&feId=" + obj.aData[1] + "&checkedItem=" + checkedItem + "&checkedLoc=" + checkedLoc;
                                                return "<a href='"+sReturn+"'>"+ obj.aData[1]+"</a>";
                                            } 
                                  },
                                  { "mData": "FE Item" },
                                  { "mData": "FE Location" },
                                  { "mData": "Pick Best" },
                                  { "mData": "MAPE" }],
                     "sPaginationType": "full_numbers",
                      "iDisplayLength": 10,
                      "iDisplayStart": 0,
                      "sEcho":"1",
                       "aoColumnDefs": [
                                           { 'bSortable': false, 'aTargets': [ 0 ] }
                                           ],
                       "aaSorting": [[ 1, "desc" ]],
                       "bDestroy" : true,
                       "bRetrieve " : true,           
    
    }); 
    
  • allanallan Posts: 64,020Questions: 1Answers: 10,555 Site admin

    how do i send the record number to the server

    The parameters DataTables sends automatically will tell you that. See the legacy documentation here.

    You would then use those parameters in your FEList1.action program to perform the required SQL actions (assuming you are using an SQL database) to get the data to display.

    Allan

  • kpandakpanda Posts: 3Questions: 1Answers: 0

    Hi,
    Is it possible to share a running example. I saw the link that you have shared. currently we have hardcoded iDisplayStart as 0 . are you saying , we need not hardcode this and data table will send this dynamically to the server side and in our server side we just need to do request.getParameter("iDisplayStart") . is this correct?

  • allanallan Posts: 64,020Questions: 1Answers: 10,555 Site admin

    Live example using the current version of DataTables (it sends different parameters): https://datatables.net/examples/server_side/simple.html .

    Allan

This discussion has been closed.