如何通过结合使角NG-网格单元编辑? [英] How to make Angular ng-grid cell editable via binding?

查看:146
本文介绍了如何通过结合使角NG-网格单元编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是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>'}

这篇关于如何通过结合使角NG-网格单元编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆