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
620
showing validation errors for bound iggrid data
posted

I am using MVC5 and Infragistics 2013.2.  My web page contains an iggrid.  I need to validate the data and indicate to the user when there is a problem.  The validation code below works fine for me when the user is editing the iggrid.  However, the iggrid may also be "prepopulated" with rows as a result of data that the view receives from the controller:

     .DataSource(Model.Products.AsQueryable())

The problem I have is that the code below is not showing validation errors in the prepopulated rows, unless the user clicks in one of the cells and makes a change.  Then, the error is displayed.

Any ideas on how to show validation errors in data that is prepopulated into the iggrid?  Many thanks.  Tory.

----------

@(Html.Infragistics()
    .Grid(Model.PvpProduct)
    .ID("igGrid")
    .Height("500px")
    .Width("100%")
    .AutoGenerateColumns(false)
    .AutoGenerateLayouts(false)
    .RenderCheckboxes(true)
    .PrimaryKey("ID")
    .Columns(column =>
    {
        column.For(x => x.FPONumber).HeaderText("FPO Number").Width("100%");

        // Many columns not shown.
    })
    .Features(feature =>
    {
        feature.Updating().ColumnSettings(cs =>
        {
            cs.ColumnSetting().ColumnKey("FPONumber").Validation(true).EditorOptions("validatorOptions:{checkValue:validateFPONumber}").Required(false);

            // Many columns not shown.
        });
    })
    .DataSource(Model.Products.AsQueryable())
    .AutoCommit(true)
    .DataBind()
    .Render()
)

<script type="text/javascript">
    function validateFPONumber(evt, ui) {
        if (ui.value.length > 9) {
            ui.message = "Invalid FPO Number.";
            return false;
        }

        return true;
    }
</script>

Parents
No Data
Reply
  • 25665
    Offline posted

    Hello Tory,

    Thank you for contacting Infragistics!

    This is the expected behavior, validation validates the data that is being modified by the end user. If you want to validate the data you have in your database I recommend you write a custom method in your model to check for what you consider valid data.

    Please let me know if you have any further questions concerning this matter.

Children