如何在 Grid 上更新时为 DevExtreme React Grid 设置状态

How to set state for DevExtreme React Grid When update on Grid

我有一个带有批处理的 DevExtreme React Grid Mode.I 想知道当我在 Grid.Please 中更新时如何在 "State" 中设置值检查我的下面的代码并建议如何做这...

设置初始状态:-

this.state = {
 GridState : []
};

加载状态中的现有数据:-

componentDidMount() {
axios.get(ConfigItem[0].APIPath+'users/UserRights/2')
.then(res => {
  console.log(res.data.data);
 this.setState({GridState:res.data.data});
})  

}

点击提交按钮时获取网格状态数据:-

onSubmitHandler = (event) => {
  event.preventDefault();
  this.dataGrid.instance.saveEditData();
  console.log(this.state.GridState); // Here I am getting existing data only but I need to get updated data also.
}

HTML 渲染:-

    <div id="data-grid-demo">
    <DataGrid
      dataSource={this.state.GridState}
      ref={ref => this.dataGrid = ref}
      keyExpr="UserAccessId"
      showBorders={true}
      onToolbarPreparing={this.onToolbarPreparing}
    >
      <Paging enabled={false} />
      <Editing
        mode="batch"
        allowUpdating={true}
        selectTextOnEditStart={true}
        startEditAction='click' />
      <Column dataField="UserAccessId" visible={false} />
      <Column dataField="MenuId" visible={false}  />
      <Column dataField="Menu" width={100} />
      <Column dataField="SubMenu" width={170} />
      <Column dataField="ViewAccess" caption="ViewAccess" dataType="boolean" width={150} >
        <CheckBox defaultValue={false} />
      </Column>
      <Column dataField="ZohoParameter"  />
      <Column dataField="Remarks"  />

    </DataGrid>


  </div>

您可以设置 DataGrid 的 onRowUpdated 属性,并从对象参数的数据字段中获取更改的行。