2013-10-14 58 views
0

排序標頭標記時ajax調用發生如何限制ajax調用。我不希望服務器端排序。我需要客戶端排序。任何幫助,將不勝感激。如何在數據排序過程中禁用服務器端Ajax命中表

代碼

function InitUserTable(params){ 
     var clientListTable= $('#clientListTable').dataTable({ 
    "bLengthChange" : false, 
    "iDisplayLength" : 10, 
    "bSort" : true, 
    "bFilter": false, 
    "bDestroy":true, 
    "sPaginationType": "full_numbers", 
    "bProcessing": true, 
    "bServerSide": true, 
    "bAutoWidth" : false, 
       "sAjaxSource": "../clients/clientDataTable.do?"+params, 
       "fnDrawCallback": function(){ 
        $("#clientListTable tbody tr").click(function(e) { 

          if ($(this).hasClass('datatablerowhighlight')) { 
           $(this).removeClass('datatablerowhighlight'); 
          } 
          else { 
           clientListTable.$('tr.datatablerowhighlight').removeClass('datatablerowhighlight'); 
           $(this).addClass('datatablerowhighlight'); 
          } 

        }); 
         }, 
       "aoColumns": [ 
             { "sTitle": "#", "mData": "index", "sClass": "center" }, 
             { "sTitle": "Client Name", "sortable":true ,"mData": "clientName", "sClass": "left" ,"fnRender": function(obj) { 
              var clientName = obj.aData.clientName; 
              var clientId = obj.aData.clientId; 
              var index= obj.aData.index; 
              var viewClient=""; 
              viewClient = "<div style='cursor:pointer;width:125px;' class='ellipsis'><u onclick='javascript:showClientInfo(\""+clientId+"\" ,\""+clientName+ "\" , \""+index+"\",this);'>"+ clientName +" </u></div>"; 
              return viewClient; 
             } }, 

             { "sTitle": "Business Type", "mData": "businessType", "sClass": "left" ,"fnRender": function(obj) { 
              var businessType = obj.aData.businessType; 
              return "<div style='width:150px;' class='ellipsis'>"+ businessType +"</div>" 

             } } 
          ] 
     }); 
    } 

回答

0

我覺得你的問題是有關使用「sAjaxSource」 DataTable.so第一次加載JSON數據,一旦數據獲取加載,搶設置對象(fnSettings())和設置sAjaxSource 或者您可以使用fnServerData攔截第一個呼叫,然後做你想做的

+0

而對於客戶端排序你可以使用sort()與對象例如。 var data = [「B」,「O」,「A」,「M」]; data.sort(); 輸出:A,B,M,O – raw

相關問題