2014-09-24 23 views
0

我想要從服務器端獲取客戶端分頁/排序和列過濾器數據提取。我使用輪詢服務器端ajax調用link並將數據推送到客戶端。但我更改了loadonce:false從服務器端獲取數據使用全部用於我的網格的列過濾器。如果loadonce:true,所有的調用都是客戶端排序和分頁,所以無法實現列過濾服務器端。我想要cliend side分頁/排序?在jqgrid服務器端搜索?

我想客戶端分頁/與服務器端柱過濾排序

請幫助我。

jQuery("#list451").jqGrid({ 
url:'getList.php?mode=result_list', 
datatype: "json", 
height: 255, 
width: 600, 
colNames:['Index','Name', 'Code','Result'], 
colModel:[ 
{name:'item_id',index:'item_id', width:65, sorttype:'integer',searchoptions:{sopt:['eq','ne','le','lt','gt','ge']}}, 
{name:'item',index:'item', width:150, sorttype:'string',searchoptions:{sopt:['eq','bw','bn','cn','nc','ew','en']}}, 
{name:'item_cd',index:'item_cd', width:100} , 
{name:'result',index:'result', width:100,sorttype:'string',searchoptions:{sopt:['eq','ne']} ], 
rowNum:50, 
rowTotal: 200, 
rowList : [20,30,50], 
loadonce:false, 
mtype: "GET", 
rownumbers: true, 
rownumWidth: 40, 
gridview: true, 
pager: '#pager451', 
sortname:'item_id', 
viewrecords: true, 
sortorder: "asc", 
caption: "Loading data from server at once" }); 
jQuery("#list451").jqGrid('filterToolbar',{searchOperators : true}); 

投票代碼如下

function poll() { 

var pollOutputJson; 
$.ajax({ 

    type: "POST", 
    url: server.php ? q = 5, 
    contentType : "application/json; charset=utf-8", 
    dataType: "json", 
    async: true, 
    cache: false, 
    success: function (data) { 
     pollOutputJson = data; 
     var samGrid = jQuery("#list5"); 
     var su = samGrid.jqGrid('addRowData', 0, pollOutputJson); 
     samGrid.setGridParam({ 
      rowNum: 15 
     }).trigger("reloadGrid"); 
    }, 
    error: function (x, e) { 
     alert("error occur"); 
    } 
}); 
setTimeout((function (param) { 
    return function() { 
     poll(); 
    }; 
})(), 180000); 
} 
+0

請告知我的原因....如果你把減號在我的問題 – 2014-09-24 12:55:48

+1

這不是一個正確的方式來問這裏在StackOverflow的問題。請隨時與Stackoverflow進行一次啓動遊覽。 FYKI:我不是downvoter ..:\ – 2014-09-24 12:56:08

回答

1

我不想評論function poll其中的代碼,我覺得非常可疑。我只想回答關於使用loadonce: true與客戶端分頁/排序的主要問題,但是從服務器加載過濾的數據(通過filterToolbar)。

您只需要使用beforeSearch回調filterToolbardatatype重置爲"json"

+0

非常感謝Oleg – 2014-09-29 07:22:05

+0

@KrishnakumarSubbaiyan:不客氣! – Oleg 2014-09-29 07:23:02