我有一个自动加载行的树形网格。目标是按树列对网格进行排序,正好在客户端上。jqGrid在客户端排序
但每次我点击排序列标题,它问题 Ajax调用进行排序,但我需要的是在就地使用本地数据排序。
我是否有不正确的网格参数,或者不在树列上的客户端排序树上工作?
排序是当前的jqGrid PARAMS是:
loadonce: true, // to enable sorting on client side
sortable: true //to enable sorting
我有一个自动加载行的树形网格。目标是按树列对网格进行排序,正好在客户端上。jqGrid在客户端排序
但每次我点击排序列标题,它问题 Ajax调用进行排序,但我需要的是在就地使用本地数据排序。
我是否有不正确的网格参数,或者不在树列上的客户端排序树上工作?
排序是当前的jqGrid PARAMS是:
loadonce: true, // to enable sorting on client side
sortable: true //to enable sorting
要获得客户端的排序工作,我需要调用reloadGrid
电网加载后:
loadComplete: function() {
jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting
}
我没有在我的应用程序的另一个网格上执行此操作,因为它被配置为使用通过另一个AJAX调用检索的数据,而不是网格直接检索的数据:
editurl: "clientArray"
datatype: "local"
我在jqGrid上使用客户端排序并在选择列表更改时检索一组新的json数据。您需要将rowTotal设置为大于或等于返回的行数,然后在重新加载网格之前将数据类型设置为'json'。
// Select list value changed
$('#alertType').change(function() {
var val = $('#alertType').val();
var newurl = '/Data/GetGridData/' + val;
$("#list").jqGrid().setGridParam({ url: newurl, datatype: 'json' }).trigger("reloadGrid");
});
// jqGrid setup
$(function() {
$("#list").jqGrid({
url: '/Data/GetGridData/-1',
datatype: 'json',
rowTotal: 2000,
autowidth: true,
height:'500px',
mtype: 'GET',
loadonce: true,
sortable:true,
...
viewrecords: true,
caption: 'Overview',
jsonReader : {
root: "rows",
total: "total",
repeatitems: false,
id: "0"
},
loadtext: "Loading data...",
});
});
$(function() {
$("#list").jqGrid({
url: '/Data/GetGridData/-1',
datatype: 'json',
rowTotal: 2000,
autowidth: true,
height:'500px',
mtype: 'GET',
loadonce: true,
sortable:true,
...
viewrecords: true,
caption: 'Overview',
jsonReader : {
root: "rows",
total: "total",
repeatitems: false,
id: "0"
},
loadtext: "Loading data...",
});
});
请解释代码,以便它变得更有教育意义。 – lpapp 2014-02-18 08:20:11
http://stackoverflow.com/questions/1329002/jqgrid-loadonce-doesnt-work-with-asp-net – queen3 2010-01-25 13:56:08