【问题标题】:Ag-Grid Prevent API.StopEditing() callback when editing next cell (Angular)编辑下一个单元格时 Ag-Grid 防止 API.StopEditing() 回调(Angular)
【发布时间】:2018-08-22 20:02:22
【问题描述】:

我目前正在为 Angular 5 开发 AG Grid。我遇到了单元格编辑功能的问题。通过我的点击事件,我使用以下代码以编程方式启用所选行列的编辑模式

selectedNods.forEach(element => {
    if (element.node.selected)
        element.node.gridApi.startEditingCell({
            rowIndex: element.node.rowIndex,
            colKey: "account"
        });
});

这很好用。但是当我为了编辑的目的进入一个单元格时, 所有其他单元格从编辑模式返回正常模式。
我想保留所有选定的行,指定的单元格应该是可编辑的,即使我正在编辑一个单元格。 请帮帮我。

【问题讨论】:

    标签: angular ag-grid ag-grid-ng2


    【解决方案1】:

    全行编辑模式将帮助您而不是 cell editing
    使用[editType]="'fullRow'" 属性。

    完成此操作后,您可以使用cellClicked 事件使行/单元格可编辑。

    (cellClicked)="onCellClicked($event)"
    

    在你的组件中,

    onCellClicked($event){
      // check whether the current row is already opened in edit or not
      if(this.editingRowIndex != $event.rowIndex) {
        console.log($event);
        $event.api.startEditingCell({
          rowIndex: $event.rowIndex,
          colKey: $event.column.colId
        });
        this.editingRowIndex = $event.rowIndex;
      }
    }
    

    Plunk - row editing ag-grid

    中查看这个实时示例

    【讨论】:

    • 是的。它有助于。谢谢帕里托什。
    猜你喜欢
    • 2020-02-19
    • 1970-01-01
    • 2019-10-26
    • 1970-01-01
    • 2019-08-24
    • 1970-01-01
    • 2020-07-09
    • 2020-07-21
    • 2019-09-12
    相关资源
    最近更新 更多