【问题标题】:Syncfusion Angular Grid - delete selected rowSyncfusion Angular Grid - 删除选定的行
【发布时间】:2019-05-17 21:45:32
【问题描述】:

我有简单的网格:

  GridSettings() {
    this.editSettings = { allowAdding: true, allowEditing: true, allowDeleting: true, showConfirmDialog: true, showDeleteConfirmDialog: false, };
    this.searchOptions = { fields: ['SoftwareSystem', 'LicenseComponentId', 'Notes'], operator: 'contains', ignoreCase: true };
    this.pageSettings = { enableQueryString: true, pageSize: 20 };
    this.filterSettings = { type: "Menu" };
    this.filter = { type: "CheckBox" };
    this.editparams = { params: { popupHeight: '300px' } };
    this.formatoptions = { type: 'dateTime', format: 'M/d/y hh:mm a' }
    this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
  }

捕捉动作完成:

actionComplete(args: EditEventArgs) {
    if (!isNullOrUndefined(args) && !isNullOrUndefined(args['data'])) {
      let itemToSave = args['data'] as SiteLicenceAllocation;
      if (this.licenseObj != undefined && this.licenseObj.value != null)
        itemToSave.LicenseComponentId = this.licenseObj.value.toString();

      if (args.requestType == 'add') {
        itemToSave.SiteId = this.selectedSite.SiteId;
        itemToSave.ObjectState = ObjectStateType.Created;
      }

      else if (args.requestType == 'delete') {
        itemToSave[0].ObjectState = ObjectStateType.Deleted;
        this.saveLicence(itemToSave[0]);
      }

      else if (args.requestType == 'save') {
        if (itemToSave.ObjectState == undefined)
          itemToSave.ObjectState = ObjectStateType.Updated;

        this.saveLicence(itemToSave);
      }
    }
  }

问题是当我选择一行并单击删除时,每次都会从网格中删除第一行。但是当我刷新页面时,我收到了很好的数据。我感到困惑的是,我在删除按钮上收到了数据列表。但是当我点击添加、更新、取消时,我会收到干净的模型。为什么删除按钮不一样,问题的根源是什么?

【问题讨论】:

    标签: angular syncfusion


    【解决方案1】:

    似乎主键列未在网格中指定。编辑和删除操作需要主键字段来标识记录/行。请参考以下链接。

    https://ej2.syncfusion.com/angular/documentation/grid/edit/#troubleshoot-editing-works-only-for-the-first-row https://ej2.syncfusion.com/angular/documentation/grid/edit/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-02
      • 1970-01-01
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多