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

How to add cell validations like we do in forms.

Open DVGY opened this issue 2 years ago • 2 comments

How can I add validations for cells,

  1. Such that it any user enter wrong input, it should show error msg.
  2. Is there any variable which tell all the entered information in react data grid is valid, like isValid

DVGY avatar Jul 05 '23 06:07 DVGY

I use to provide technical fields on my Row:

type Row = RowData & { errors?: ExtractFromRowData<RowData> };

/* Should ends like 
 * type Row = { field: string; errors?: { field?: YourOwnErrorType } }
 */
renderCell: (row: { field, errors }) => 
<SomeWrapperShowingErrorInAWay error={errors?.field}>
  <HowYouDisplayYourCell>{field}</HowYouDisplayYourCell>
</SomeWrapperShowingErrorInAWay>

When I generate Rows or onRowChange, you should generate errors from the RowData.

splacentino avatar Jul 05 '23 08:07 splacentino

@splacentino can you pls elaborate this more. I am kind of confused here

DVGY avatar Jul 05 '23 12:07 DVGY

Closing as this is beyond of the scope of RDG editing.

amanmahajan7 avatar Apr 15 '25 17:04 amanmahajan7