How to disable the sorting click on table header when server side data is still processing?

How to disable the sorting click on table header when server side data is still processing?

janardhanjanardhan Posts: 3Questions: 0Answers: 0
edited October 2010 in General
Hi All,
I'm doing the server side sorting in datatable plugin .Data takes 4-5 seconds to load, in the mean time if the user clicks on other headers it will again trigger the ajax call.
Please help me on how to restrict the user when the servers side data is still in processing state.
Is there any initial function where i can check custom Flag status & stop the sortable.??

Highly appreciate the quick response.

Thanks,
Janardhan

Replies

  • janardhanjanardhan Posts: 3Questions: 0Answers: 0
    Please help!!!1
  • cdaiglecdaigle Posts: 57Questions: 0Answers: 0
    Have you tried "bProcessing" : true as an initialization parameter ? This will put a small dialog over the table while dataTables is processing data.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It takes 4-5 seconds to get a server-side processing data array! Ouch. So you get that delay for every page change, sort, filter etc? Sounds like that needs optimisation... However, you have override the server-side processing calls by using http://datatables.net/usage/callbacks#fnServerData - and putting a blocker in if you want (perhaps until fnInitComplete is fired).

    Allan
  • janardhanjanardhan Posts: 3Questions: 0Answers: 0
    edited October 2010
    Hi Allan,
    First, thanks a lot for replying.
    It's an optimised one though :).But it takes around 1-3 seconds as the display data is complex & its based on the user data (ranges from low to high).
    I'm displaying the 250 rows in the table by doing the complex json parsing (heavy UI intense rows) via ajax (also complex biz logic along with sort :)) so is the accepted delay.
    I'm using the fnServerData for making an ajax call & json data parsing call.I'm not doing pagination or filter using datatables.
    I would like to restrict the user from triggering the sort on other column when sort is still processing.(I even dont want to shift the image icon (up or down) to other column.

    Below is my code.
    [code]
    var oTable= $('#userTable').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": false,
    "bProcessing": false,
    "bSortable": true,
    "bInfo": false,
    "bAutoWidth": false,
    "aoColumns": [{
    "bSortable": false
    }, //checkbox
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    { "asSorting": [ "desc", "asc" ] },
    {
    "bSortable": false //Status
    }],
    aaSorting: [[2, 'desc']],
    "bServerSide": true,
    "sAjaxSource": "/account/UserLists",
    "fnServerData": function(sSource, aoData, fnCallback){
    var initLoad = true;
    if (typeof sortIndex != 'undefined' || typeof sortOrder != 'undefined') {
    initLoad = false;
    }
    //To get the selected column & order.
    sortIndex = fnGetKey(aoData, "iSortCol_0");
    sortOrder = fnGetKey(aoData, "sSortDir_0");
    if (sortIndex == 2) {
    sortIndex = 0;
    }
    else if (sortIndex != 0 && sortIndex != 1) {
    sortIndex = sortIndex - 1;
    }
    if (sortOrder == "asc") {
    sortOrder = 1;
    }
    else {
    sortOrder = 0;
    }
    if (!initLoad) { //To avoid duplicate call on first load.
    getResponse(userStatus, start, rows); //This function triggers the getJSON call & //displays the data after parsing.Not using the sAjaxSource & fncallback. Also using the custom processing icon & //text.
    }
    }
    });

    [/code]
This discussion has been closed.