Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何取消角度ui网格中的单元格编辑?_Angularjs_Angular Ui Grid_Ui Grid - Fatal编程技术网

Angularjs 如何取消角度ui网格中的单元格编辑?

Angularjs 如何取消角度ui网格中的单元格编辑?,angularjs,angular-ui-grid,ui-grid,Angularjs,Angular Ui Grid,Ui Grid,我在beginCellEdit事件中有一些情况 gridApi.edit.on.beginCellEdit($scope, function(rowEntity, colDef, event) { var scope = angular.element(event.currentTarget).scope(); var selectedRowIndex = scope.rowRenderIndex; var s

我在beginCellEdit事件中有一些情况

       gridApi.edit.on.beginCellEdit($scope, function(rowEntity, colDef, event) {
            var scope = angular.element(event.currentTarget).scope();
            var selectedRowIndex = scope.rowRenderIndex;
            var selectedColumnName = scope.col.name;

            if ($scope.gridOptions.data[selectedRowIndex-1][selectedColumnName].trim()=='') {      
                alert("You cannot enter the value in this cell");
                // At this place I want to cancel edit and return focus to grid
            } 
        })
是否有任何默认或类似的方法可以轻松取消单元格编辑并将焦点返回网格


谢谢大家!

您可以看看这个示例,以获得条件可编辑字段

控制器:

var cellEditable = function($scope){
  if($scope.row.entity.oldId4===undefined)
    return false;
  return $scope.row.entity.oldId4!=$scope.row.entity.id4;
}
cellEditableCondition : cellEditable
Gridoptions->columnDefs:

var cellEditable = function($scope){
  if($scope.row.entity.oldId4===undefined)
    return false;
  return $scope.row.entity.oldId4!=$scope.row.entity.id4;
}
cellEditableCondition : cellEditable

您可以看看这个示例,以获得条件可编辑字段

控制器:

var cellEditable = function($scope){
  if($scope.row.entity.oldId4===undefined)
    return false;
  return $scope.row.entity.oldId4!=$scope.row.entity.id4;
}
cellEditableCondition : cellEditable
Gridoptions->columnDefs:

var cellEditable = function($scope){
  if($scope.row.entity.oldId4===undefined)
    return false;
  return $scope.row.entity.oldId4!=$scope.row.entity.id4;
}
cellEditableCondition : cellEditable

另一种方法是广播iuigrideditcontents.events.END\u CELL\u EDIT事件,如下所示:

scope.$broadcast("uiGridEventEndCellEdit");
唯一的缺点是它将关闭所有处于编辑模式的单元格

仅供参考:以下内容对我不起作用:

 gridApi.rowEdit.setRowsClean([gridRow.entity]);

另一种方法是广播iuigrideditcontents.events.END\u CELL\u EDIT事件,如下所示:

scope.$broadcast("uiGridEventEndCellEdit");
唯一的缺点是它将关闭所有处于编辑模式的单元格

仅供参考:以下内容对我不起作用:

 gridApi.rowEdit.setRowsClean([gridRow.entity]);

确保按照@CAK2所示广播字符串文字“uiGridEventEndCellEdit”。或变量值
uiGridEditConstants.events.END\u CELL\u EDIT
。请注意,
uiGridEditConstants
是在“ui网格编辑模块”中声明的角度常数,需要注入控制器(注入服务的方式)。也不要混淆
uiGridConstants
uiGridEditConstants
!确保按照@CAK2所示广播字符串文字“uiGridEventEndCellEdit”。或变量值
uiGridEditConstants.events.END\u CELL\u EDIT
。请注意,
uiGridEditConstants
是在“ui网格编辑模块”中声明的角度常数,需要注入控制器(注入服务的方式)。也不要混淆
uiGridConstants
uiGridEditConstants