【发布时间】:2011-10-24 20:25:09
【问题描述】:
据我所知,这里和互联网上的其他几个地方都曾提出过这个问题。我已经尝试了在 StackOverflow 网站上可以找到的所有解决方案,结果相同,但没有解决我的问题。
我想从数据库中加载一次数据,然后在客户端做所有的排序操作。 loadonce 属性听起来应该可以处理这个问题,但它似乎对我不起作用。我还尝试在各种事件处理程序中将数据类型设置为本地,但没有成功。
这是我用来实例化网格的代码。
$('#people_SelectedContacts').jqGrid({
ajaxGridOptions:{
type: "POST"
},
datatype: function(data){
$.ajax(klg.getAppRoot()+"AJAX/GetMatterProfileContacts",{
data: JSON.stringify({
MatterProfileID: $('#MatterProfileID').val()
}),
success: function(data){
var contacts = data.ReturnValues;
var mygrid = $("#people_SelectedContacts")[0];
mygrid.addJSONData(contacts);
},
complete: function(){
$("#people_SelectedContacts").setGridParam({datatype:'local'});
}});
},
loadonce: true,
colNames:['lecID','lrlID','mjID','Role','Name','Company/Court', 'Business Phone', 'Email', 'Docket #'],
colModel:[
{name:'LegalEntityContactID', hidden:true},
{name:'LegalRoleLookupID', hidden:true},
{name:'MatterJurisdictionID', hidden:true},
{name:'LegalRoleLookupName', index:'legalrole'},
{name:'FullName',index:'name'},
{name:'Company',index:'company'},
{name:'BusinessPhone',index:'bussphone'},
{name:'Email',index:'email'},
{name:'DocketNumber',index:'email'}
],
sortable: true,
jsonReader: {
root:'MatterProfileContacts',
repeatitems: false,
id:"MatterProfileContactID"
}
});
数据正确加载到网格中,但正如我所说,排序命令全部执行并再次访问服务器。谁能指出我正确的方向?我从标准 HTML 表切换到 JQGrid 的唯一原因是为了排序和分组。如果我不能让客户端排序工作,那就没用了。
感谢 Stack Overflow 社区。p>
【问题讨论】:
标签: javascript jquery ajax jqgrid