Skip to content

Commit 219ea71

Browse files
karlkeremmportuga
authored andcommitted
feat(gridEdit): Pass triggerEvent to cellEditableCondition fn call
Need to know what triggered the edit request to be able to decide if edit should be allowed or not.
1 parent b9197b1 commit 219ea71

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

misc/tutorial/201_editable.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ __ColumnDef Options__:
4444
- `enableCellEdit` (default: `false` for columns of type `'object'`, `true` for all other columns) - `true` will enable
4545
editing and `false` will disable it.
4646
- `cellEditableCondition` (default: `true`) Can be set to a boolean or a function that will be called with the cellScope
47-
to determine if the cell should be invoked in edit mode.
47+
and triggerEvent to determine if the cell should be invoked in edit mode.
4848
- `type` (default: `'string'`) If set to `'number'`, `'boolean'` or `'date'` the default editor provided for editing will be numeric
4949
or boolean or date editor respectively. If set to `'object'` the column will not be editable by default. Be aware that this
5050
`type` column is also used for other purposes within ui-grid, including the sorting logic.

src/features/edit/js/gridEdit.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@
147147
* If false, then editing of cell is not allowed.
148148
* @example
149149
* <pre>
150-
* function($scope){
151-
* //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed
150+
* function($scope, triggerEvent){
151+
* //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
152152
* return true;
153153
* }
154154
* </pre>
@@ -209,8 +209,8 @@
209209
* @description If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed.
210210
* @example
211211
* <pre>
212-
* function($scope){
213-
* //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed
212+
* function($scope, triggerEvent){
213+
* //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
214214
* return true;
215215
* }
216216
* </pre>
@@ -592,10 +592,10 @@
592592
}
593593
}
594594

595-
function shouldEdit(col, row) {
595+
function shouldEdit(col, row, triggerEvent) {
596596
return !row.isSaving &&
597597
( angular.isFunction(col.colDef.cellEditableCondition) ?
598-
col.colDef.cellEditableCondition($scope) :
598+
col.colDef.cellEditableCondition($scope, triggerEvent) :
599599
col.colDef.cellEditableCondition );
600600
}
601601

@@ -732,7 +732,7 @@
732732
return;
733733
}
734734

735-
if (!shouldEdit($scope.col, $scope.row)) {
735+
if (!shouldEdit($scope.col, $scope.row, triggerEvent)) {
736736
return;
737737
}
738738

0 commit comments

Comments
 (0)