Background:
I came across a strange behavior in jqGrid: when the callback cellattrreturns a string containing the "style", the grid becomes messy.
See an example:
HTML:
<table id="grid"></table>
Javascript
$("#grid").jqGrid({
datatype: "local",
height: "auto",
data: [{column1: "row1col1", column2: "row1col2" },
{column1: "row2col2", column2: "row2col2" }],
colNames: ['Column1', 'Column2'],
colModel: [
{
name: 'column1',
index: 'column1',
cellattr: function (rowId, val, rawObject, cm, rdata) {
attrValue = (rawObject.column2 == 'row2col2') ? 'GangnamStyleAttribute' : 'GangnamAttribute';
return ' customAttr="' + attrValue + '"';
},
width: 100
},
{
name: 'column2',
index: 'column2',
width: 100
}],
caption: "Qaru Example",
});
$("#grid").jqGrid('setGridParam');
Also see jsfiddle
In the above example, it cellattrreturns' customAttr = "GangnamAttribute" 'for the first line and' customAttr = "GangnamStyleAttribute" for the second line.
As you can see from jsfiddle , the first row is displayed correctly, and the second is confused: the first column is not shown, and the second column is displayed instead of the first.
, cellattr -, " ".
:
- , , " "?