react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

pass rowIdx to renderEditCell

Open dalmolinz opened this issue 1 year ago • 0 comments

rowIdx is passed to renderCell but not to renderEditCell. This PR fixes that unless there's any reason otherwise.

In my use case, I'm rendering a custom input component that updates a react-hook-form context, and it references the form field using the dot notation e.g. persons.1.height etc.

The status quo with rdg only exposing row, I have to expand my rows objects to contain their own indexes, or do a rows.findIndex, which forces me to declare columns inside the render cycle and deal with memoization etc. Neither are ideal, especially because the solution is right under our noses.

The proposed PR makes it trivially simple to achieve that:

renderEditCell: ({ rowIdx, column }) => {
  return <input name={`myField.${rowIdx}.${column.key}`} />;
}

dalmolinz avatar May 10 '24 00:05 dalmolinz