子网格中的 jqGrid 冻结列
jqGrid Frozen Columns in a Subgrid
我知道如果从 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:frozencolumns 启用子网格,冻结列将不起作用。
我的理解是冻结在父网格中不起作用,但它应该在子网格中起作用?
但是当我尝试在子网格中冻结列时它不起作用?这是否意味着冻结的列在父网格和子网格中都不起作用。
如果您使用 subgrid as grid,那么 jqGrid 只会在 "subgrid row" 中创建空的 <div>
,其中可以放置 any 信息。因此,您可以在 div 中创建具有 any 特征的新网格。您可以使用冻结的原因列创建网格。
我通过修改旧答案的演示为您创建了 the demo。结果如下所示
我使用 CSS
标记了冻结列的 header
.ui-jqgrid .frozen-div .ui-th-column { background: #f0dcdd; color: black; }
subgrid的代码如下
subGrid: true,
subGridRowExpanded: function (subgridId, rowid) {
var $subgrid = $("<table id='" + subgridId + "_t'></table>");
$subgrid.appendTo("#" + subgridId);
$subgrid.jqGrid({
datatype: "local",
data: $(this).jqGrid("getLocalRow", rowid).files,
colNames: ["Name", "Filetype", "col3", "col4"],
colModel: [
{name: "name", width: 130, key: true, frozen: true},
{name: "filetype", width: 130, frozen: true},
{name: "col3", width: 130},
{name: "col4", width: 130}
],
height: "100%",
rowNum: 10,
sortname: "name",
shrinkToFit: false,
autowidth: true,
idPrefix: "s_" + rowid + "_"
}).jqGrid("setFrozenColumns");
}
我使用 shrinkToFit: false
来防止子网格列的默认收缩以及设置子网格宽度的 autowidth: true
。
该代码适用于 jqGrid 3.7 或我最近发布的免费 jqGrid 3.8(参见 here and here), but in case of usage more old versions of jqGrid you can need to trigger jqGridAfterGridComplete
event (see the answer)。
我知道如果从 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:frozencolumns 启用子网格,冻结列将不起作用。
我的理解是冻结在父网格中不起作用,但它应该在子网格中起作用?
但是当我尝试在子网格中冻结列时它不起作用?这是否意味着冻结的列在父网格和子网格中都不起作用。
如果您使用 subgrid as grid,那么 jqGrid 只会在 "subgrid row" 中创建空的 <div>
,其中可以放置 any 信息。因此,您可以在 div 中创建具有 any 特征的新网格。您可以使用冻结的原因列创建网格。
我通过修改旧答案的演示为您创建了 the demo。结果如下所示
我使用 CSS
标记了冻结列的 header.ui-jqgrid .frozen-div .ui-th-column { background: #f0dcdd; color: black; }
subgrid的代码如下
subGrid: true,
subGridRowExpanded: function (subgridId, rowid) {
var $subgrid = $("<table id='" + subgridId + "_t'></table>");
$subgrid.appendTo("#" + subgridId);
$subgrid.jqGrid({
datatype: "local",
data: $(this).jqGrid("getLocalRow", rowid).files,
colNames: ["Name", "Filetype", "col3", "col4"],
colModel: [
{name: "name", width: 130, key: true, frozen: true},
{name: "filetype", width: 130, frozen: true},
{name: "col3", width: 130},
{name: "col4", width: 130}
],
height: "100%",
rowNum: 10,
sortname: "name",
shrinkToFit: false,
autowidth: true,
idPrefix: "s_" + rowid + "_"
}).jqGrid("setFrozenColumns");
}
我使用 shrinkToFit: false
来防止子网格列的默认收缩以及设置子网格宽度的 autowidth: true
。
该代码适用于 jqGrid 3.7 或我最近发布的免费 jqGrid 3.8(参见 here and here), but in case of usage more old versions of jqGrid you can need to trigger jqGridAfterGridComplete
event (see the answer)。