加载保存的选定数据ag-grid表

问题描述

ag-grid 表有一些问题,我使用的是 Vue.js 框架。

我正在尝试导入该表中选定的数据,例如:
我加载了一些数据并且我正在选择一些行,有一个按钮可以刷新该数据,但是如果刷新数据,它将清除所选数据。我仍然有保存所选数据的状态。

这是我的模板:

<b-button v-ripple.400="'rgba(0,207,232,0.15)'" 
  variant="outline-info" 
  pill 
  @click="synchronization"
>
  Synchronize
  <b-spinner v-if="syncing" small class="mr-1" label="Small Spinner" />
</b-button>

<div class="order-table">

  Selected: {{ this.selectedDataStringPresentation }}

  <ag-grid-vue style="width: 100%; height: 500px;" 
    class="ag-theme-alpine" 
    :gridOptions="gridOptions" 
    :columnDefs="columnDefs" 
    :rowData="ordersList" 
    rowSelection="multiple" 
    rowMultiSelectWithClick="true" 
    @selection-changed="getSelectedRows" 
    :animateRows="true"
    :floatingFilter="true"
  >
  </ag-grid-vue>
</div>

如您所见,我实现了一个按钮和 ag-grid。
getSelectedRows 函数的外观如下:

getSelectedRows() {
  this.selectednodes = this.gridApi.getSelectedRows();
  this.selectedData = this.selectednodes.map(node => node);
  this.selectedDataStringPresentation = this.selectedData.map(node => node.id).join(',');
}

这是一个 columnDefs 示例和一些 gridOptions(我不知道那是什么):

this.gridOptions = {};
this.columnDefs = [{
  rowMultiSelectWithClick: true,headerName: 'ID',field: 'id',filter: true,maxWidth: 50,resizable: true,pinned: true,cellRenderer: (params) => {
    const route = {
      name: "orders-view",params: {
        id: params.value
      }
    };

    const link = document.createElement("a");
    link.href = this.$router.resolve(route).href;
    link.innerText = params.value;
    link.addEventListener("click",e => {
      e.preventDefault();
      this.$router.push(route);
    });
    return link;
  }
}]

如何加载已保存的选定数据?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)