我有同樣的麻煩和解決它。
我有三個網格,每個cellEditableTemplate我註冊ng單擊單元格,從而選擇單元格編輯的開始和結束事件的下一個來源。該setMethod()
,只是設置全局變量$scope.thisGridUpdate
$scope.targetTypeDefs = [ {
field : 'id',
displayName : '#',
enableCellEdit : false,
width : 50
}, {
field : 'desc',
displayName : 'Type Description',
enableCellEdit : true,
cellEditableCondition : 'row.selected',
editableCellTemplate : '<input ng-class="\'colt\' + col.index" \
ng-input="COL_FIELD" \
ng-model="COL_FIELD" \
ng-model-options="{ updateOn : \'default blur\' }" \
ng-click="setMethod(\'saveTargetType\')"/>'
} ];
$scope.targetTypeGrid = {
data : 'targetTypeData',
showSelectionCheckbox : true,
selectWithCheckboxOnly : true,
multiSelect : false,
enableCellEditOnFocus : true,
columnDefs : 'targetTypeDefs'
};
接下來你只是趕上並捕獲結束單元格編輯事件在你的正常活動ngGridEventEndCellEdit
消費者,像這樣:
$scope.setMethod = function(name) {
console.log("clicked on ", name);
$scope.thisGridUpdate = name;
};
$scope.$on('ngGridEventEndCellEdit', function(evt, other) {
console.log("ended edit on ", $scope.thisGridUpdate, "with " , evt.targetScope.row.entity);
console.log(evt.targetScope.row);
if ($scope.thisGridUpdate === 'saveServerType') {
EntityMgt.saveServerType(evt.targetScope.row.entity);
}
else if ($scope.thisGridUpdate === 'saveOsVersion') {
EntityMgt.saveOsVersion(evt.targetScope.row.entity);
}
else if ($scope.thisGridUpdate === 'saveTargetType') {
EntityMgt.saveTargetType(evt.targetScope.row.entity);
}
});
爲什麼downvote? – sports 2015-05-12 21:12:36