且构网

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

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

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

使用思路setCell 向不应编辑的单元格添加类不可编辑单元格"的方法是正确的.你只选择了错误的地方来做这件事.在自定义格式化程序内部,网格直到最后都无法构建.我建议您使用 loadCompletegridComplete 以检查 当前页面 的网格包含并将某些单元格标记为不可编辑.

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.