我正在尝试将jqgrid集成到我的xhtml页面上,并使用服务器端分页支持点击jqgrid寻呼机上的'next','prev'按钮。我想用点击'next'/'prev'按钮刷新存储在页面变量数组中的数据的网格,但是如果我使用'local'作为数据类型,我无法设置'records'参数。网格。我的代码如下所示 -
function reloadJQGrid(){
$("#list").setGridParam({datatype:'local'});
$("#list").setGridParam({localReader:{repeatitems: false}});
var myData1 ="{\"total\":1,\"page\":1,\"records\":50,\"rows\":[" +
"{\"id\":\"1\",\"examineeid\":\"123455\",\"firstname\":\"testfirst1\",\"middlename\":\"middle1\",\"lastname\":\"testlast1\",\"dateofbirth\":\"2007-10-01\",\"gender\":\"Male\",\"emailaddress\":\"test1@test.com\",\"customfield1\":\"nodata\",\"customfield2\":\"nodata\",\"customfield3\":\"nodata\",\"customfield4\":\"nodata\",\"createdby\":\"dfgdfg\",\"createddate\":\"2007-10-01\",\"modifiedby\":\"try\",\"modifieddate\": \"2007-10-01\",\"accountname\":\"TRGG\",\"legacyexamineeid\":\"1234\",\"legacysystem\":\"test1\",\"groups\":\"testgroup\"}," +
"{\"id\":\"2\",\"examineeid\":\"123\",\"firstname\":\"testfirst1\",\"middlename\":\"middle1\",\"lastname\":\"testlast1\",\"dateofbirth\":\"2007-10-01\",\"gender\":\"Male\",\"emailaddress\":\"test1@test.com\",\"customfield1\":\"nodata\",\"customfield2\":\"nodata\",\"customfield3\":\"nodata\",\"customfield4\":\"nodata\",\"createdby\":\"ifgfg\",\"createddate\":\"2007-10-01\",\"modifiedby\":\"itr\",\"modifieddate\": \"2007-10-01\",\"accountname\":\"YTTT\",\"legacyexamineeid\":\"1234\",\"legacysystem\":\"rdtr\",\"groups\":\"testgroup\"}" +
"] }";
$("#list").jqGrid("clearGridData", true);
$("#list").setGridParam({data:myData1});
$("#list").trigger("reloadGrid");
}
关于这个的任何指针都会有所帮助,我试图将数据类型用作'json',这适用于带有数据的json文件,但我不想用json数据创建临时文件,而是我的变量获取刷新数据,我想用同样的方法重新加载下一组数据。
答案 0 :(得分:1)
根据jqGrid Options wiki page,“Records”是一个只读属性。
请尝试使用“reloadJQGrid”功能中的最后一步。
var records = 5000; //read this value from your server return string
$("#list").setGridParam({recordtext: "View {0} - {1} of "+records});
更新后,您的功能如下所示:
function reloadJQGrid(){
$("#list").setGridParam({datatype:'local'});
$("#list").setGridParam({localReader:{repeatitems: false}});
var myData1 ="{\"total\":1,\"page\":1,\"records\":50,\"rows\":[" +
"{\"id\":\"1\",\"examineeid\":\"123455\",\"firstname\":\"testfirst1\",\"middlename\":\"middle1\",\"lastname\":\"testlast1\",\"dateofbirth\":\"2007-10-01\",\"gender\":\"Male\",\"emailaddress\":\"test1@test.com\",\"customfield1\":\"nodata\",\"customfield2\":\"nodata\",\"customfield3\":\"nodata\",\"customfield4\":\"nodata\",\"createdby\":\"dfgdfg\",\"createddate\":\"2007-10-01\",\"modifiedby\":\"try\",\"modifieddate\": \"2007-10-01\",\"accountname\":\"TRGG\",\"legacyexamineeid\":\"1234\",\"legacysystem\":\"test1\",\"groups\":\"testgroup\"}," +
"{\"id\":\"2\",\"examineeid\":\"123\",\"firstname\":\"testfirst1\",\"middlename\":\"middle1\",\"lastname\":\"testlast1\",\"dateofbirth\":\"2007-10-01\",\"gender\":\"Male\",\"emailaddress\":\"test1@test.com\",\"customfield1\":\"nodata\",\"customfield2\":\"nodata\",\"customfield3\":\"nodata\",\"customfield4\":\"nodata\",\"createdby\":\"ifgfg\",\"createddate\":\"2007-10-01\",\"modifiedby\":\"itr\",\"modifieddate\": \"2007-10-01\",\"accountname\":\"YTTT\",\"legacyexamineeid\":\"1234\",\"legacysystem\":\"rdtr\",\"groups\":\"testgroup\"}" +
"] }";
$("#list").jqGrid("clearGridData", true);
$("#list").setGridParam({data:myData1});
$("#list").trigger("reloadGrid");
var records = 5000; //read this value from your server return string
$("#list").setGridParam({recordtext: "View {0} - {1} of "+records});
}