0

在对标头标签进行 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>"

                                      } }
                            ]
         } );
     }
4

2 回答 2

0

我认为你的问题与 DataTable.so 首先使用“sAjaxSource”加载 json 数据,一旦你的数据被加载,抓住设置对象(fnSettings())并设置 sAjaxSource,或者你可以使用 fnServerData 拦截第一个调用,然后执行你想要什么

于 2013-10-14T09:24:24.087 回答
0

使 bServerSide 为假。它不会去服务器端进行排序

于 2015-11-05T11:54:46.433 回答