Is it possible to limit ng-grids enabled Cell Selection to one column?

£可爱£侵袭症+ 提交于 2019-12-24 14:26:08

问题


Is it possible to limit the editable modus of ng-grids cells to cells in one column only?
I currently use enableCellEditOnFocus: true and this globally allows all cells to be editable. I do have a specific editableCellTemplate for one column, by I would like to have all other columns "readonly".
Any suggestions for a beginner making his first baby-steps with angularjs and ng-grid?

This is the relevant setup of the grid currently:

        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:


Yes, according to this documentation you can use the enableCellEdit column definition property to set only that column up for editing. You may have to disable this property for the rest of your columns.



来源:https://stackoverflow.com/questions/18427707/is-it-possible-to-limit-ng-grids-enabled-cell-selection-to-one-column

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