如何在 JQGrid 的行编辑中禁用某些单元格的编辑?

2022-01-19 00:00:00 javascript jqgrid

当我单击网格的任何一行时,所有可编辑的列都变为可编辑的.

When I click on any row of my Grid, All editable columns become editable.

我希望某些列可以在每一行上分别进行编辑.

I want some of the columns to be editable on each row separately.

                 Column 1,   Column 2,     Column 3             
ROW Number 1 - editable,     non-editable, non-editable  
ROW Number 2 - non-editable, editable,     non-editable    
ROW Number 3 - editable,     non-editable, non-editable  

提前致谢

推荐答案

如果你使用 内联编辑模式 并且想要动态地决定该行的哪些单元格可以编辑,例如基于单元格的包含,您可以通过以下方式执行此操作我描述了 这里.你也可以用另一种方法来做到这一点:

If you use inline editing mode and want to decide dynamically which cells of the row will be editable for example based on the contain of the cells you can do this in the way which I described here. You can do this with another method also:

$(this).jqGrid('setColProp', 'YouColumnName', {editable:false});

所以你应该把 editable 设置为 falsetrue before 调用 editRow 方法.这样你就可以实现任何你想要的逻辑.

So you should just set editable to false or true before calling of editRow method. In the way you can implement any logic which you want.

更新: Free jqGrid 允许定义 可编辑 作为回调函数.请参阅维基文章.它允许在某些行中使列可编辑,而对其他行保持不可编辑.

UPDATE: Free jqGrid allows to define editable as callback function. See the wiki article. It allows to make the column editable in some rows and holding non-editable for other rows.

相关文章