0

我正在尝试在我的 xhtml 页面上集成 jqgrid,并在单击 jqgrid 寻呼机上的“下一个”、“上一个”按钮时使用服务器端分页支持。我想在单击“下一个”/“上一个”按钮时使用存储在页面变量中的数组中的数据刷新网格,但如果我使用“本地”作为数据类型,我无法在网格。我的代码如下所示 -

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 数据创建临时文件,而是用数据刷新我的变量,我想用同样的方法重新加载下一组数据。

4

1 回答 1

1

根据 jqGrid Options wiki page,“记录”是一个只读属性。

请在“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});

}

于 2012-09-27T20:25:26.823 回答