问题描述
我希望从服务器端获取客户端分页/排序和列过滤器数据.我已经使用轮询服务器端ajax调用并将数据推送到客户端.但是我更改了 loadonce:false 以从服务器端获取数据,该数据已完全用于我的网格的列过滤器.如果loadonce:true,则所有调用都是客户端排序和分页,因此无法实现列过滤器服务器端.
I want client side pagination/sorting and column filter data fetch from server side. i have use polling server side ajax call link and push the data to client side .But i change the loadonce : false to get data from server side its use full for column filter for my grid. if loadonce :true all the call's are client side sorting and paging so not able to achieve the column filter server side.
我希望使用服务器端列过滤器进行客户端分页/排序
I want client side pagination/sorting with server side column filter
请帮助我.
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);
}
推荐答案
我不想注释function poll
我发现非常怀疑的代码.我只想回答关于使用loadonce: true
进行客户端分页/排序的主要问题,但是要从服务器加载过滤后的数据(通过filterToolbar
).
I don't want to comment function poll
which code I find very suspected. I wanted just answer on your main question about usage of loadonce: true
with client side pagination/sorting, but loading filtered data (by filterToolbar
) from the server.
您只需要使用filterToolbar
的beforeSearch
回调将datatype
重置为"json"
.
You need just use beforeSearch
callback of filterToolbar
to reset datatype
to "json"
.
这篇关于我想要客户端侧面分页/排序吗?在jqgrid的服务器端搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!