Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Async/Sync Validation Separation
posted

Hi, 

I have a couple of questions regarding async validators as we are trying to use them in our project.  It seems that there's no way to separate the updateOn feature of async validation from regular validation which seems odd as we would like to allow things like maxlength, required etc. to be performed on 'change' but this seems irresponsible to do on our async ones, where it puts out an API call every time the user types to check something (in our case if a value is unique within a certain scope).  So the only option seems to be to change the entire form-field's onChange to 'blur', unless I'm missing something.

Secondly, the same issue happens when applying validation to a grid - the validationTrigger can only be set in the grid as a whole, which is even more annoying since there is probably only one or 2 columns that will require this specific unique API call.  Is there any way to set this on a per column basis that I'm unaware of?

Any help you could give would be greatly appreciated.

Thanks!

Parents
No Data
Reply
  • 600
    Offline posted

    Hello Adam,

    Thank you for posting into our community!

    I have been looking into your question and after an investigation I have determined that the updateOn property of the FormGroup, i.e., the row, and each FormControl, i.e., the cells of the row, is determined by the validationTrigger property of the IgxGrid which could be either the default value "change" or "blur". It is applied to each control when the FormGroup is created, i.e., when entering edit mode for the first time for a given row.

    Having this in mind, setting the updateOn property for individual FormControls currently is not supported out of the box.

    What I would suggest, in order to have this feature implemented in any of our future releases, is logging this as a feature request in our GitHub repository here. Remember when submitting your idea to explain the context in which a feature would be used and why it is needed.

    This will give you the opportunity to directly communicate with our development team regarding this matter and get notifications whenever new information is available.

    In the meantime, in order to avoid having multiple API calls when the user types inside the cell editor, I would suggest setting the validationTrigger property to "blur".

    Also, a possible workaround I could suggest, in order to have "different" updateOn properties for different columns, is setting the validationTrigger property to "blur" as mentioned above, using an igxCellEditor directive with an input element, and triggering the validation whenever the input event occurs via the updateCell method as mentioned in our Validation topic here. This way you can imitate the updateOn: "change" behavior for the columns that should be validated when the user types inside the cell editor.

    Here could be found a small sample demonstrating my suggestion.

    Please let me know if you need any further assistance regarding this matter.

    Sincerely,
    Riva Ivanova
    Associate Software Developer

Children
No Data