当jqgrid reloadGrid填充空数据时

时间:2018-01-27 13:21:44

标签: jqgrid

hi iam使用jqgrid reloadGrid和本地json。当重装网格为空或未填充时 这个演示demo 这是我的代码

function FillGrid() { 

   var objstr =   [{ id: "12", Name: "Name 41", PackageCode: "8443123a", get: 315 },
            { id: "22", Name: "Name 12", PackageCode: "8314423a", get: 585 },
            { id: "32", Name: "Name 12", PackageCode: "8314423a", get: 56485 }
            ]

    var col = Object.keys(objstr).map(function (itm) { return objstr[itm]; });

 //   $("#" + idgrid).setGridParam({ data: col }).trigger("reloadGrid", {  page: 1 });

    $("#jqg1").setGridParam({ data: objstr, datatype: 'local' }).trigger('reloadGrid');
 }

1 个答案:

答案 0 :(得分:0)

在我看来,您在FillGrid中输入了错误。固定版本

function FillGrid() { 
   var objstr = [
     { id: "12", Name: "Name 41", PackageCode: "8443123a", get: 315 },
     { id: "22", Name: "Name 12", PackageCode: "8314423a", get: 585 },
     { id: "32", Name: "Name 12", PackageCode: "8314423a", get: 56485 }
   ];

   $("#packages").setGridParam({
     data: objstr,
     datatype: 'local'
   }).trigger('reloadGrid');
 }

的工作原理。见https://jsfiddle.net/dnfk8hmr/154/