是否可以将ng-grid启用的Cell选择限制为一列?

时间:2013-08-25 09:46:02

标签: angularjs ng-grid

是否可以将ng-grid细胞的可编辑模式限制为仅在一列中的细胞? 我目前使用 enableCellEditOnFocus:true ,此全局允许所有单元格可编辑。我确实有一个特定的editableCellTemplate用于一列,我希望所有其他列“readonly”
有关初学者使用angularjs和ng-grid制作他的第一个婴儿步骤的任何建议吗?

这是当前网格的相关设置:

        var app = angular.module('myCoolGridApp', ['ngGrid']);
        app.controller('MyCtrl', function ($scope, $http) {

            $scope.gridOptions = {
                data: 'myData',
                enableCellSelection: true,
                enableRowSelection: false,
                enableCellEditOnFocus: true,
                jqueryUITheme: true,
                columnDefs: 'colDefs'
            };

            var myCellEditableTemplate = "<input ng-class=\"'colt' + col.index\" ng-input=\"COL_FIELD\" ng-model=\"COL_FIELD\" ng-blur=\"updateEntity(col, row)\"/>";

            $scope.colDefs = [
                    {field: 'group'},
                    {field: 'user'},
                    {field: 'id', displayName: 'ID', editableCellTemplate: myCellEditableTemplate},             
                    {field: 'last_login_date'},
                    {field: 'status'}
                    ];

            $scope.updateEntity = function (column, row) {
                // code for saving data to the server next...
            }
        });

1 个答案:

答案 0 :(得分:2)

是的,根据this documentation,您可以使用enableCellEdit列定义属性仅设置该列进行编辑。您可能必须为其余列禁用此属性。