J'ai une définition de colonne de grille ui comme ci-dessous:fonction d'appel de la définition Grille
$scope.gridOptions.columnDefs = [
{ name: 'Year 3', field: 'Year 3', cellEditableCondition: function($scope) { return $scope.row.entity[$scope.col['field']+'_editable']; },
editableCellTemplate: 'ui-grid/dropdownEditor', editDropdownValueLabel: 'yoy', editDropdownOptionsArray: $scope.yoyGrowthDropDown,
cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
if (row.entity[col['field']+'_editable'])
return 'red';
else
return "";
}
},
{ name: 'Year 4', field: 'Year 4', cellEditableCondition: function($scope) { return $scope.row.entity[$scope.col['field']+'_editable']; }, editableCellTemplate: 'ui-grid/dropdownEditor', editDropdownValueLabel: 'yoy', editDropdownOptionsArray: $scope.yoyGrowthDropDown,
cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
if (row.entity[col['field']+'_editable'])
return 'red';
else
return "";
}
},
{ name: 'Year 5', field: 'Year 5', cellEditableCondition: function($scope) { return $scope.row.entity[$scope.col['field']+'_editable']; }, editableCellTemplate: 'ui-grid/dropdownEditor', editDropdownValueLabel: 'yoy', editDropdownOptionsArray: $scope.yoyGrowthDropDown,
cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
if (row.entity[col['field']+'_editable'])
return 'red';
else
return "";
}
},
{ name: 'Year 6-10', field: 'Year 6-10', cellEditableCondition: function($scope) { return $scope.row.entity[$scope.col['field']+'_editable']; }, editableCellTemplate: 'ui-grid/dropdownEditor', editDropdownValueLabel: 'cagr', editDropdownOptionsArray: $scope.cagrDropDown,
cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
if (row.entity[col['field']+'_editable'])
return 'red';
else
return "";
}
}
];
Pour chaque celluleEditableCondition & cellClass, une fonction est appelée. Je ne veux pas définir de fonction pour chaque définition de colonne. Au lieu de cela, je veux le définir une fois et l'appeler pour chaque colonne.
Quelqu'un peut-il s'il vous plaît laissez-moi savoir sur quelle étendue avons-nous pour définir la fonction et comment l'appelons-nous?
Merci!
Ce n'est pas une question relative angulaire, mais un AngularJS. Permettez-moi de modifier vos tags – trichetriche