上次我在我的应用程序中更改了 jqGrid(4.6.0 到 free-jqgrid 4.8.0)和 jQuery(1.7.2 到 2.1.3)的版本。
在我的父网格中,我有 2 个可见列,每个列的宽度为 100 像素,在子网格中,有 5 个可见列,每个列的宽度为 200 像素。在以前的版本中,子网格位于顶部,因此我可以查看子网格中的所有列,而无需调整任何列的大小。
更改后获得相同的结果如果我想查看子网格中的所有列,我需要做解决方法并添加空列(我不想这样做)。有什么我可以做的吗?
它可以与父网格中更大的第二列一起使用,但我不想调整它的大小,我更喜欢将其保留为 100 像素。
网格的定义:
function loadFirstGrid() {
var data = {
"page": "1",
"records": "3",
"rows": [
{ "DataID": "1", "DataDesc": "Test 1", "DataTitle": "Test 1" },
{ "DataID": "2", "DataDesc": "Test 2", "DataTitle": "Test 2" },
{ "DataID": "3", "DataDesc": "Test 3", "DataTitle": "Test 3" }
]
};
$("#FirstGrid").jqGrid({
datatype: "xml",
mtype: "GET",
contentType: "text/xml",
colNames: ['DataID', 'DataDesc', 'DataTitle'],
colModel: [
{ name: 'DataID', index: 'DataID', hidden: true, key: true },
{ name: 'DataDesc', index: 'DataDesc', width: 100 },
{ name: 'DataTitle', index: 'DataTitle', width: 100 }
],
rowNum: 10000,
datatype: "jsonstring",
datastr: data,
ignoreCase: true,
sortname: 'DataDesc',
sortorder: 'asc',
emtyrecords: "Nothing to display",
viewrecords: true,
sortable: true,
height: "100%",
shrinkToFit: false,
loadonce: true,
scrollOffset: 0,
width: 2000,
caption: 'First Grid',
subGrid: true,
subGridRowExpanded: loadSubGrid,
gridview: false
});
}
function loadSubGrid(subgrid_id, row_id) {
var data = {
"page": "1",
"records": "3",
"rows": [
{ "SubGridID": "1", "FirstCol": "Test 1", "SecondCol": "Test 1", "ThirdCol": "Test 1", "FourthCol": "Test 1", "FifthCol": "Test 1" },
{ "SubGridID": "2", "FirstCol": "Test 2", "SecondCol": "Test 2", "ThirdCol": "Test 1", "FourthCol": "Test 1", "FifthCol": "Test 1" },
{ "SubGridID": "3", "FirstCol": "Test 3", "SecondCol": "Test 3", "ThirdCol": "Test 1", "FourthCol": "Test 1", "FifthCol": "Test 1" }
]
};
var subgrid_table_id;
var dataID = $("#FirstGrid").jqGrid('getRowData', row_id).DataID;
subgrid_table_id = subgrid_id + "_SubGrid";
$("#" + subgrid_id).html("<div><table id='" + subgrid_table_id + "' class='scroll'></table></div>");
$("#" + subgrid_table_id).jqGrid({
datatype: "xml",
mtype: "GET",
contentType: "text/xml",
colNames: ['SubGridID', 'FirstCol', 'SecondCol', 'ThirdCol', 'FourthCol', 'FifthCol'],
colModel: [
{ name: 'SubGridID', index: 'SubGridID', hidden: true, key: true },
{ name: 'FirstCol', index: 'FirstCol', editable: false, width: 200 },
{ name: 'SecondCol', index: 'SecondCol', width: 200 },
{ name: 'ThirdCol', index: 'ThirdCol', width: 200 },
{ name: 'FourthCol', index: 'FourthCol', width: 200 },
{ name: 'FifthCol', index: 'FifthCol', width: 200 },
],
rowNum: 10000,
datatype: "jsonstring",
datastr: data,
ignoreCase: true,
sortname: 'FirstCol',
sortorder: 'asc',
emtyrecords: "Nothing to display",
viewrecords: true,
sortable: true,
height: "100%",
shrinkToFit: false,
loadonce: true,
scrollOffset: 0,
width: 1900,
caption: 'SubGrid',
gridview: false
});
}
编辑:这里
有演示
谢谢!