如何在数据表中排序时禁用服务器端ajax命中

时间:2013-10-14 08:49:52

标签: javascript jquery jsp jquery-datatables

在排序标头标签时,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>"

                                      } }
                            ]
         } );
     }

2 个答案:

答案 0 :(得分:0)

我认为你的问题与DataTable有关。首先使用“sAjaxSource”加载json数据,加载数据后,抓取设置对象(fnSettings())并设置sAjaxSource 或者您可以使用fnServerData拦截第一个调用,然后执行您想要的操作

答案 1 :(得分:0)

将bServerSide设为false。它不会在服务器端进行排序