Hi,
I've the following issue related to Numeric Editor validator. In a MVC application I've defined in a controller the following grid column:
ColumnUpdatingSetting uSetTipoProdotto = new ColumnUpdatingSetting(); uSetTipoProdotto.ColumnKey = "TipoProdotto"; EditorValidatorOptions validOptTipoProdotto = new EditorValidatorOptions(); validOptTipoProdotto.BodyAsParent = false; validOptTipoProdotto.MinValue = 1; validOptTipoProdotto.MaxValue = 99; validOptTipoProdotto.Required = true; validOptTipoProdotto.CustomErrorMessage = "Il valore deve essere compreso tra 1 e 99 "; uSetTipoProdotto.NumericEditorOptions.ValidatorOptions = validOptTipoProdotto; uSetTipoProdotto.Validation = true; updating.ColumnSettings.Add(uSetTipoProdotto);
The goal is tp allow the values between 1 and 99 but the cose I've pasted is not working. What am I doing wrong?
Thank you in advance.
Kind regards.
Simone
Hi Simone,
Thanks for using Infragistics jquery controls.
The ValidatorOption exposed by XxxEditorValidator property of grid updating, uses shared EditorValidatorOptions class. That class exposes all options available for igValidator. However, if igValidator is attached to igEditor, then a particular editor may not support all options. For example, numeric editors (igEditor with type numeric, currency, percent) have their own min/maxValue and validator for min/max values is performed only for those options of igEditor. It means that application should use Max/MinValue properties of NumericEditorOptions.In your codes you should replace
validOptTipoProdotto.MinValue = 1;validOptTipoProdotto.MaxValue = 99;
by
uSetTipoProdotto.NumericEditorOptions.MaxValue = 99;uSetTipoProdotto.NumericEditorOptions.MinValue = 1;
There is no need to use
uSetTipoProdotto.Validation = true;
because validation was already enabled by
uSetTipoProdotto.NumericEditorOptions.ValidatorOptions = not_null_value;
The Validation is an alternative and it can be used to enable validation without setting ValidatorOptions. Example:
ColumnUpdatingSetting uSetTipoProdotto = new ColumnUpdatingSetting();uSetTipoProdotto.ColumnKey = "TipoProdotto";uSetTipoProdotto.NumericEditorOptions.MaxValue = 99;uSetTipoProdotto.NumericEditorOptions.MinValue = 1;uSetTipoProdotto.Validation = true;updating.ColumnSettings.Add(uSetTipoProdotto);
Note: if your application does not use igLoader (you may look at source of generated html), then in order for validators to work, corresponding js/css files should be available on client. If validator-error-message does not appear or it has wrong appearance, then application may include those files explicitly:
<link type="text/css" href="pathToLocation_probably:/css/structure/modules/infragistics.ui.validator.css" rel="stylesheet" /><script type="text/javascript" src="pathToLocation_probably:/js/modules/infragistics.ui.validator.js"></script>
thank you very much for the detailed explanation! Now it works when I edit a row but not when I add a row? Shall I add some more options?
thank you
regards