Make only some cells editable in ngGrid?

时光怂恿深爱的人放手 提交于 2019-12-01 03:28:31

问题


I have an ngGrid that shows a few records with basically key / value content. Now, I would like to make some of these records editable.

Using the enableCellEditing features of ngGrid, I can enable or disable editin for a complete column - but what if I only want to enable it for some rows in that column? Is there any way to dynamically configure this for each row?


回答1:


Late answer, but ng-grid (which is now being redone as ui-grid) now has a cellEditableCondition that you can use to make only some cells editable.

You just add it in your gridOptions :

enableCellEditOnFocus: true,
cellEditableCondition: 'row.rowIndex !== 2' //can edit all rows except for the third

Example plunker

This feature availble only after ng-grid 2.0.9




回答2:


You can use cellEditableCondition like below code

{ field: 'planTypeName',displayName:$rootScope.commonProperty.name,enableCellEditOnFocus: true,enableCellEdit:true,cellEditableCondition: function( $scope ) { return $scope.row.entity.sts=='A'; }},



来源:https://stackoverflow.com/questions/20268522/make-only-some-cells-editable-in-nggrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!