Skip to content

the validator doesn't work with customEditor? #1041

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

Closed
bennnjamin opened this issue Feb 14, 2017 · 8 comments
Closed

the validator doesn't work with customEditor? #1041

bennnjamin opened this issue Feb 14, 2017 · 8 comments

Comments

@bennnjamin
Copy link
Contributor

bennnjamin commented Feb 14, 2017

I have a custom column like this:

<TableHeaderColumn dataField="phone" editable={{validator: phoneNumberValidator}} dataSort={true} dataFormat={phoneFormatter} customEditor={ { getElement: createPhoneEditor } } editable={{validator: phoneNumberValidator}}>Phone Number</TableHeaderColumn>

However adding the validator does not do anything here. Do I need to add the validator to my phoneEditor class? Or how can I invoke the validator in a customEditor?

@AllenFang
Copy link
Owner

@bennnjamin, why you have two editable on a TableHeaderColumn and make sure the validator return a bool value or an object, the object format you can check this example

Let me know if you still got in stuck, thanks 👍

@bennnjamin
Copy link
Contributor Author

bennnjamin commented Feb 15, 2017

@AllenFang
I have removed the second editable here:

<TableHeaderColumn editable={{validator: phoneNumberValidator}} dataField="phone" dataSort={true} dataFormat={phoneFormatter} customEditor={ { getElement: createPhoneEditor } }>Phone Number</TableHeaderColumn>

This is my validator, I copied it from your link and changed the name.

function phoneNumberValidator(value){ console.log("validating"); const response = { isValid: true, notification: { type: 'success', msg: '', title: '' } }; if (!value) { response.isValid = false; response.notification.type = 'error'; response.notification.msg = 'Value must be inserted'; response.notification.title = 'Requested Value'; } else if (value.length < 100) { response.isValid = false; response.notification.type = 'error'; response.notification.msg = 'Value must have 10+ characters'; response.notification.title = 'Invalid Value'; } return response; }

The function phoneNumberValidator is still never called, because I do not see the console.log() when I edit the cell, and then click outside to trigger onBlur. If you would like to see more code let me know.

@AllenFang
Copy link
Owner

After my investigation, I found I dont call validator for the component which is custom by user, so this is a bug issue, BTW, I'll fix it but release it on v3.0.0, I've stop all the development for v2.x and ready for release v3.0.0 to production.

Thanks

@AllenFang AllenFang reopened this Feb 16, 2017
@AllenFang AllenFang changed the title How do you use a validator with customEditor? the validator doesn't work with customEditor? Feb 16, 2017
@bennnjamin
Copy link
Contributor Author

Thanks for following up! I am currently using 3.0 beta so please let me know when you push a fix and I will install the latest version and test.

@AllenFang
Copy link
Owner

AllenFang commented Feb 17, 2017

yap, I will

AllenFang added a commit that referenced this issue Feb 20, 2017
@AllenFang
Copy link
Owner

Fixed on v3.0.0-beta.12, BTW, v3.0.0 ready to end the beta, will be release to production recently

Thanks

@ramovald
Copy link

I'm using version 4.3.1 and
I'm having the same problem using validator on cell edit. console.log is never shown so the function is not being called. Could you please verify it is being called?
Thanks.

@bennnjamin
Copy link
Contributor Author

@ramovald This project is no longer being maintained. @AllenFang is recommending to switch to https://github.com/react-bootstrap-table/react-bootstrap-table2

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

No branches or pull requests

3 participants