'How to set state for DevExtreme React Grid When update on Grid
I have an DevExtreme React Grid with Batch Mode.I would like to know how to set value in "State" when I updated in Grid.Please check my below code and advise how to do this...
Setting Initial State:-
this.state = {
GridState : []
};
Load Existing Data in State:-
componentDidMount() {
axios.get(ConfigItem[0].APIPath+'users/UserRights/2')
.then(res => {
console.log(res.data.data);
this.setState({GridState:res.data.data});
})
}
Get the Grid State Data when clicking on submit button :-
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 Render:-
<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>
Solution 1:[1]
You can set the onRowUpdated prop of the DataGrid and from the data field of the object parameter get a changed row.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Semenov Dmitry |
