Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] validate user's input when using react-datasheet as data input form #280

Open
wangchen-ca opened this issue Apr 22, 2021 · 1 comment

Comments

@wangchen-ca
Copy link

Is there a way to correct or rollback user's input if user's input is not valid according some business logic? for example, a percentage input have range [1-100], if current value is 80, user change to 102, our code change it to 100 or roll back to 80 and alert a invalid warning to user.

Now I am able to use onCellsChanged to add a new css to have different color if the value being changed. I can use this way to display red font when value is invalid if above quest can't be achieved.

Thanks,
Chen

@wangchen-ca wangchen-ca changed the title validate user's input when using react-datasheet as data input form [Question] validate user's input when using react-datasheet as data input form Apr 22, 2021
@fny
Copy link

fny commented Aug 30, 2021

There is no built in method to accomplish this out of the box, but you can use attributesRenderer to accomplish it similar to the method shown for adding hints.

attributesRenderer={(cell) => (cell.error ? { 'data-error': cell.error, style: { color: 'red'} } : { })}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants