我有一个没有数据初始化的网格,但在一些用户交互后会加载数据。我的网格还使用“分组”功能,例如:
ordersGrid.jqGrid({
url: '',
mtype: '',
datatype: 'local',
colNames: ['Order', 'Task #', 'Type', 'Status', 'Assignee', 'Current Location',
'Dest Location', 'Change No', 'Net Patched', 'SAN Patched', 'Select'],
colModel: [
{ name: 'Order', index: 'Order ID'},
{ name: 'Task #', index: 'Task #'},
{ name: 'Type', index: 'Type'},
{ name: 'Status', index: 'Status'},
{ name: 'Assignee', index: 'Assignee'},
{ name: 'Current Location', index: 'Current Location'},
{ name: 'Dest Location', index: 'Dest Location'},
{ name: 'Change No', index: 'Change No'},
{ name: 'Net Patched', index: 'Net Patched'},
{ name: 'SAN Patched', index: 'SAN Patched'},
{ name: 'Select', index: 'Select', width:'75px', classes: "SelectColumn",
editable: true, edittype:'checkbox', editoptions: {value:"True:False"},
formatter:"checkbox", formatoptions: {disabled: false}}
],
gridview: true,
height: 'auto',
pager: ordersGridPager,
viewrecords: true,
grouping: false, //Set to true once data is loaded.
groupingView: {
groupField: ['Order'],
groupColumnShow: [false]
},
loadError: function(error) {
console.error(error);
}
});
如果我在网格初始化期间将属性“分组”设置为 true,我会在页面上看到以下错误:
Uncaught TypeError: Cannot read property 'stype' of undefined
如果在将分组设置为 true 之前网格上有数据,则不存在此错误。如果我将分组设置为假,一切都很好。
问题是即使没有数据,我也不想看到我的“订单”列。我怎样才能做到这一点?
这是一个解决问题的 JS Fiddle:http: //jsfiddle.net/qrjZD/1/