如何在AG网格中一次仅编辑一行?角度7

时间:2020-10-21 10:51:50

标签: angular7 ag-grid

我想一次只编辑一行,并阻止用户编辑其他行,直到关闭第一行或关闭与此有关的任何可编辑行。

现在,我有一个在自定义组件上开发的编辑按钮。设置标志以限制不能正常工作。

自定义按钮组件:

  template: `
<button type="button" *ngIf="isNew == true" style="width:50px;" (click) = "onEditClick()" (onchange)="onChangeTest()" data-action-type="view" class="btn btn-iconsize1 btn-link lni-pencil-alt">
</button>
<button type="button"  *ngIf="isNew == false" (click) = "onUpdateClick()" data-action-type="view" class="fa fa-check-circle text-success iconsize3">
</button>
<button type="button" *ngIf="isNew == false" (click) = "onCancelClick()" data-action-type="view" class="fa fa-times-circle text-danger iconsize3">
</button>`,

   onEditClick() {
    console.log(this.params);
    this.params.data['isEdited'] = true;
    // storing old data for comparison
    this.editParams = JSON.parse(JSON.stringify(this.params.data));
    this.isNew = !this.isNew;
    if (this.setFlag === true) {
       alert('close');
    } else {
      this.params.api.startEditingCell({
        rowIndex: this.params.node.rowIndex,
        colKey: 'mtmFlag'
        });
    }
    this.setFlag = true;        
    // else {
    //   alert('already on edit');
    // }
}

调用按钮组件的主要组件:

constructor(private DataService: ResourceService, private UnderscoreService: UnderscoreServices) {
    this.columnDefs = [
        {
            headerName: 'Edit',
            field: 'action',
            sortable: true,
            filter: false,
            cellRenderer: 'buttonRenderer',  // this is the button component
            cellRendererParams: {
                cancelOtherRowEditors: this.cancelOtherRowEditors.bind(this),
            },
            width: 100,
            pinned: 'left'
        },

}

让我知道是否可以冻结或提示您限制多行编辑。

0 个答案:

没有答案