AardVark71
AardVark71

Reputation: 4126

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

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...
            }
        });

Upvotes: 1

Views: 3853

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67336

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.

Upvotes: 2

Related Questions