使用 setLabel 方法为冻结列的 headers 应用 CSS
apply CSS for frozen column's headers using setLabel method
我正在尝试使用以下代码在 jqgrid 中为 headers 应用背景颜色:
$("#" + gridId).jqGrid("setLabel", "Action", "Website", { "background": "red" });
它正在工作,但是如果列被冻结,它就不会工作。请帮忙。
冻结列的实现在 jqGrid 4.6.0 中存在错误。实现您的要求的最简单方法:升级到 free jqGrid 4.13.1 and to use labelClasses
property of colModel
(see the demo)。在列 header 上设置 CSS 将是最小的问题。免费的 jqGrid 是在与 jqGrid 4.6 相同的许可 (MIT/GPLv2) 下提供的。
只有当您目前确实不能更新到免费的 jqGrid 时,您才需要手动设置列 header 的 CS 样式。相应的代码可能像
var $grid = $("#" + gridId);
$($grid[0].grid.hDiv)
.find("tr.ui-jqgrid-labels th")
.eq(pos)
.add(
$($grid[0].grid.fhDiv)
.find("tr.ui-jqgrid-labels th")
.eq(pos))
.css({ background: "red" });
其中 pos
是列的索引。
要使用 columnChooser
,您应该包括 ui.multiselect.css
、jquery-ui.min.js
和 ui.multiselect.js
。您将在 jqGrid 的 plugins 子目录中找到 ui.multiselect.*
。
我正在尝试使用以下代码在 jqgrid 中为 headers 应用背景颜色:
$("#" + gridId).jqGrid("setLabel", "Action", "Website", { "background": "red" });
它正在工作,但是如果列被冻结,它就不会工作。请帮忙。
冻结列的实现在 jqGrid 4.6.0 中存在错误。实现您的要求的最简单方法:升级到 free jqGrid 4.13.1 and to use labelClasses
property of colModel
(see the demo)。在列 header 上设置 CSS 将是最小的问题。免费的 jqGrid 是在与 jqGrid 4.6 相同的许可 (MIT/GPLv2) 下提供的。
只有当您目前确实不能更新到免费的 jqGrid 时,您才需要手动设置列 header 的 CS 样式。相应的代码可能像
var $grid = $("#" + gridId);
$($grid[0].grid.hDiv)
.find("tr.ui-jqgrid-labels th")
.eq(pos)
.add(
$($grid[0].grid.fhDiv)
.find("tr.ui-jqgrid-labels th")
.eq(pos))
.css({ background: "red" });
其中 pos
是列的索引。
要使用 columnChooser
,您应该包括 ui.multiselect.css
、jquery-ui.min.js
和 ui.multiselect.js
。您将在 jqGrid 的 plugins 子目录中找到 ui.multiselect.*
。