score:1
first i use oncellvaluechange
and not oneditcellchangecommitted
. and i dynamically changed the value.
const oncellvaluechange = (value: grideditcellvalueparams) => {
// get the row
const rowindex = rows.findindex(row => row.id === value.id);
if (rowindex >= 0) {
const row = rows[rowindex] as any;
// validate if changed
if (value.field in row && row[value.field] !== value.value) {
const data = { id: row.id, [value.field]: value.value };
// sending to api
api.product.update(data).then(res => {
const newrows = [...rows] as any;
if (res.success) {
// change to new value
newrows[rowindex][value.field] = value.value;
} else {
// change to old value
newrows[rowindex][value.field] = row[value.field];
}
setrows(newrows);
});
}
}
};
Source: stackoverflow.com
Related Query
- Material UI Data Grid Cell Edit revert commit
- Custom sort for custom render cell Data Grid Material UI
- React project - Material UI Data grid display nested array object in a cell
- how to make material data grid width to fill the parent component in react js
- How to remove cell border in Data Grid component of Material-Ui
- How to save state of column visibility in material ui data grid
- How can I show edit button in column cell while hovering over table row in Material UI Table?
- How to make react data grid table cell editable and focused on click of a button without performing a double click action
- Material UI Data Grid not working on adding column other than "ID"?
- How to style the cell edit component in material table?
- Change cell value dynamically in MUI Data Grid
- Material UI Data Grid first column fixed
- Enable to update my table after an edit with react data grid
- using api to call users and material ui data grid to show users
- Material UI data grid filter not working when using renderCell in a field
- React Material UI Table/ Data Grid show only rows but not columns
- React Material UI Grid Item doesn`t render after data update
- How to have multi line cell in React data grid
- Material UI and Grid system
- Material UI grid with independent scrolling columns
- How to use data attributes with Material Design React?
- ReactJS - Using material UI Grid spacing
- Make child of Material UI Grid item stretch to fit the remaining height of the parent container
- How to hide the overflow content in material ui table cell instead of wrapping
- Is it possible to use CSS Grid in place of Material UI's grid component?
- How to pass percentage value to width to React data grid column
- Material-UI Data Grid onSortModelChange Causing an Infinite Loop
- How to add a new row for grid item in material ui?
- Getting data from TableRow component in Material UI
- Show action only on row hover in material-UI v5 data grid
More Query from same tag
- most trivial React Router usecase not working - Route won't render
- Fetch creating infinite loop
- How can I animate between 2 states in React and see both states during transition
- Autocomplete Search Via Another Paramter
- React Props - can not get data
- How to handle object and Array in react native?
- TypeScript and File upload types
- Could not find router reducer in state tree, it must be mounted under "router"
- Export data and Fixed Data Table
- Storing image in base64 format in MERN stack
- How to dynamically insert data into "react-minimal-pie-chart"
- how to in nested object get value from parent object in javascript?
- Light House: Manifest's short_name will be truncated when displayed on homescreen
- React children is a function: How to define TypeScript type correctly?
- Using Contexts that take props with React Router
- How to access React from outside the App?
- How to collect user input for retrieving data in reactjs?
- can not move location and create marker mapbox react
- How to bind action creator to component in redux thunk
- React component giving no-unused-expression error in map
- While trying to pass image from res.data.photo to useContext I am getting Cannot read property 'data' of undefined
- Image in next js
- 'Product' s defined but never used in react?
- TypeError: filtredItems.map is not a function
- How to render a Component if the prop is a component?
- How to execute useState dynamically from strings in react hooks?
- How can you programmatically resize a column using react-table
- How to call child submit method from another child component
- how to convert <script> tag in react?
- ReacJS Axios patch request URL with state not working