且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JQGrid:根据内容动态设置单元格不可编辑

更新时间:2023-02-09 18:53:58

使用 setCell 将类'not-editable-cell'添加到应该不可编辑的单元格的方法是正确的。你只选择了错误的地方。在自定义格式化器内部,网格可能尚未构建到最后。我建议你使用 loadComplete gridComplete 检查当前页面的网格包含,并将某些单元格标记为不可编辑。

The idea to use setCell method to add class 'not-editable-cell' to the cells which should be not-editable is correct. You choose only the wrong place to do this. Inside of custom formatter, the grid can be not yet built till the end. I recommend you to use loadComplete or gridComplete to examine the grid contain of the current page and mark some cells as not-editable.

我准备了示例来证明这一点。与您的示例中一样,所有具有测试文本的单元格都标记为不可编辑。在这种方式中,您可以检查一个单元格并将另一个单元格标记为不可编辑。

I prepared an example which demonstrate this. Like in your example all cells having "test" text are marked as non-editable. In the way you can examine one cells and mark another cells as non-editable.