问题
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