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}],
...
更新资料
在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; iRow = iRow + 1) {
row = $grid[0].rows[iRow];
className = row.className;
isPosted = false;
if ($.inArray('jqgrow', className.split(' ')) > 0) { // $(row).hasClass('jqgrow')
if (iCol > 0) {
isPosted = $(row.cells[iCol]).find(">div>input:checked").length > 0;
}
if (postedDateCol > 0) {
mycell = row.cells[postedDateCol];
mycelldata = mycell.textContent || mycell.innerText;
isPosted = mycelldata.replace(/^\s+/g, "").replace(/\s+$/g, "") !== "";
}
}
}
}
catspeake
相关分类