如何通过结合使角NG-网格单元编辑?网格、单元、编辑、NG

2023-09-13 02:48:55 作者:深刺人心

只是NG-电网开始了。我需要做单个细胞(即对于给定的行和列)基于属性的在我的网格阵列布尔值进行编辑。这将是巨大的,如果我可以简单地绑定到数组属性打开(或关闭)单元格编辑。不过,我没有看到此选项可用。难道我忽略的东西,不NG-网格支持这个开箱?如果不是这样,任何建议,我怎么能实现此功能?

Just starting out with ng-grid. I need to make individual cells (i.e. for a given row and column) editable based on the boolean value of a property in my grid array. It would be great if I could simply bind to the array property to turn on (or off) cell editing. However, I don't see this option available. Did I overlook something, does ng-grid support this out of the box? If not, any suggestions as to how I could implement this feature?

推荐答案

我不熟悉的东西一样,开箱即用。

I'm not familiar with something like that out of the box.

我会为每一个单元的单元模板,并把有两个div - 一个分区用于查看和编辑单格,然后加上NG-展示给每个并将其绑定到布尔属性,指示细胞是否可编辑还是不行。

I would create a cell template for each cell and put there two divs - one div for viewing and one div for editing, and then add ng-show to each and bind it to the boolean property that indicates whether the cell is editable or not.

例如: http://jsfiddle.net/FP7Jt/

cellTemplate: '<div class="ngCellText"><div ng-show="!row.entity.edit">{{row.getProperty(col.field)}}</div>' +     
   '<div ng-show="row.entity.edit" class="ngCellText"><input type="text" ng-model="row.entity.age"/></div></div>'}