我可以在jqgrid的cellattr中更改列宽吗?

问题描述:

我可以在cellattr中更改列宽吗?我尝试过:

Can I change column width in cellattr? I tried this:

cellattr: function(rowId, value, rowObject, colModel, arrData) {
        return ' style= width: 100% !important; ';
    }

但是没有变化.我没有在colModel中放置宽度,而在cellattr中放置了宽度,似乎网格默认具有最大宽度,因此列内的文本被剪切掉了.

But there were no change. I didn't put width in colModel and put width in cellattr, it seems that the grid has max width for default so the texts inside the column is cutted.

cellattr可用于指定列的单个单元格(<td>元素)的属性. 列宽是所有单元格的通用宽度.不过,如果您需要为列的所有单元格分配样式属性,则应在代码中使用引号:

cellattr can be used to specify attributes of individual cells (<td> elements) of the column. The width of the column is the common width of all cells. Nevertheless if you need to assign style attribute to all cells of the column you should use quotes in your code:

cellattr: function () {
    return ' style="width: 100% !important;"';
}

如果执行此操作,将会看到style="width: 100% !important;"属性将分配给该列的所有<td>元素.我仍然不确定是否会遵循您期望的结果.

If you would do this you will see that the style="width: 100% !important;" attribute will be assigned to all <td> elements of the column. I still not sure that it will follows to results which you expect.