jqGrid有一个名为Posted的列.根据客户如何配置网格,它可以定位在不同的位置,但始终保持不变.
如果已发布列的值为True,我需要更改行的背景颜色
我在下面尝试了colmodel但是alert(rdata.Posted)显示总是未定义.
如果此行中的已发布列的值为true,如何更改行的背景颜色?
我查看了许多Oleg和其他改变背景颜色的解决方案,但他们使用的是硬编码列号.
colModel: [
{"cellattr":function(rowId, tv, rawObject, cm, rdata) {
if (rdata.Posted)
return 'class="jqgrid-readonlycolumn"';
return '';
}
,"label":"Klient","name":"Klient_nimi","classes":null,"hidden":false},
{"label":null,"name":"Posted","editable":true,"width":0,
"classes":null,"hidden":true}],
...
Run Code Online (Sandbox Code Playgroud)
更新
在update2中,Oleg建议使用rowattr.我还需要在操作列中隐藏内联删除按钮和自定义发布按钮.我在loadComplete下面是usijng代码.如何使用rowattr实现这一点?
var LoadCompleteHandler = function () {
var iCol = getColumnIndexByName($grid, 'Kinnitatud'),
postedDateCol = getColumnIndexByName($grid, 'Kinkuup'),
cRows = $grid[0].rows.length,
iRow,
row,
className,
isPosted,
mycell,
mycelldata,
i, count,
cm = $grid.jqGrid('getGridParam', 'colModel'),
l,
iActionsCol = getColumnIndexByName($grid, '_actions');
l = cm.length;
if (iCol > 0 || postedDateCol > 0) {
for (iRow = 0; iRow < cRows; …
Run Code Online (Sandbox Code Playgroud) 我想遍历网格对象中包含的所有数据.我的网格有一个包含子网格对象的定义,并以这种方式创建
var grid = $(gridID);
var pager = $(pagerID);
grid.jqGrid({
url: GetBaseWSUrl() + 'MyWs.asmx/MyMethod',
colNames: ['UMLT', 'FF', 'PC'],
colModel: [
{ name: 'Name', index: 'Name', width: 180, template: colTextTemplate },
{ name: 'AlertFF', index: 'AlertFF', width: 22, align: 'center', sortable: false, formatter: "checkbox", formatoptions: { disabled: false} },
{ name: 'AlertPC', index: 'AlertPC', width: 22, align: 'center', sortable: false, formatter: "checkbox", formatoptions: { disabled: false} }
],
[...]
subGrid: true,
subGridOptions: {
"plusicon": "ui-icon-triangle-1-e",
"minusicon": "ui-icon-triangle-1-s",
"openicon": "ui-icon-arrowreturn-1-e",
"reloadOnExpand": true, …
Run Code Online (Sandbox Code Playgroud)