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);
        });
      }
    }
  };

Related Query

More Query from same tag