在LoadComplete上重新设置网格数据

时间:2016-08-22 21:31:39

标签: jqgrid

我有一个jqgrid,我想在准备就绪时重置网格数据。我有理由这样做。我的实际问题很复杂,但这是我创建的一个简单演示。

Here是我创建的一个演示,但问题是在loadcomplete上设置数据似乎不会显示网格中的数据。网格只是空的。

          var mydata = 
                [
                    {id:"1", DocGroupName: "x", DocList: "y", Mandatory: "z"}
                ];

                var mydata2 = [
                    {id:"2", DocGroupName: "yy", DocList: "rr", Mandatory: "gg"},
                     {id:"3", DocGroupName: "zz", DocList: "rr", Mandatory: "gg"}
                ];

            $("#list").jqGrid({
                datatype: "local",
                data: mydata,
                height: "auto",
              colNames: ['id', 'Document Group Name','Document Name','No of Mandatory'],
                colModel :[
                    {name:'id', index:'id', width:55},
                    {name:'DocGroupName', index:'DocGroupName', width:90, editable: true},
                    {name:'DocList', index:'DocList', width:90, editable: true },
                    {name:'Mandatory', index:'Mandatory', width:90, editable: true}

                ],
                loadComplete: function(data)
                {

                  $('#list').jqGrid('clearGridData').jqGrid('setGridParam', {
                   data: mydata
                   }).trigger('reloadGrid', [{ page: 1 }]);
                },
                pager: '#pager',
                rowNum:10,
                rowList:[10,20,30],
                sortname: 'idcustomers',
                sortorder: 'asc',
                viewrecords: true,
                gridview: true,
                caption: 'Customers',
                cellEdit: true,
                cellsubmit: 'clientArray'
            });

0 个答案:

没有答案