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
385
Data Annotation with igGrid
posted

Hello,

 

i am using NetAdvantage 2012.1 and would like to know if grid editor are supporting DataAnnotation validation.

Thank you

 

Hardis

Parents
  • 6279
    Verified Answer
    posted

    Hi Hardis,

    Yes, any igEditor that you use in the igGrid's Updating feature can have data annotation validation.

    It's currently not described in the documentation and in the igEditors data annotation validation sample, but here's a breakdown of the logic that you need to be aware of:

    1.  The data annotation validation is handled by the igValidator's errorLabel option - you can see more details on it here: https://www.igniteui.com/help/api/2019.1/ui.igvalidator#options:errorMessage 
    2. Each igEditor you use can have its own set ot validation options configured via the validatorOptions option (more info at https://www.igniteui.com/help/igvalidator-migration-topic#options_changes
    3. When using the igGrid's Updating feature, you can use the columnSettings option (https://www.igniteui.com/help/iggrid-columnmoving-propertyreference#columnSettings) to tweak the igEditor used for a specific column. The editorOptions options is the one to take note of.

    When we put the knowledge for all of these together, you're almost ready with the data annotation validation.  The final piece of the puzzle is to have a SPAN, LABEL or DIV element on your page that has the data-valmsg-for attribute that corresponds to the errorLabel you've set for the igValidator, used for the validation of an igEditor used by the igGrid Updating feature. For example:
    [code]<span class="field-validation-valid" data-valmsg-for="ProductIDValidationError" data-valmsg-replace="true"></span>[/code]


    I know it may sound difficult, but it's not :). To make sure I'm not lying to you, I've attached a simple HTML page to my reply where you can see the data annotation validation in action.
    Currently only the ProductID column is configured to have it, but I think that's enough to illustrate the concept. 

    Let us know if you have any trouble or further questions.

    Cheers!
    Borislav 

    t69721.zip
Reply Children