Hi, I am using the following MVC Helper to generate iggrid. I saw multiple samples for email validation, but there are only show email validation for simple controls. How can I add email validation with a regex for the below bolded column in the sample below. Also is there an option to add placeholder for columns in RowEditDialog template
@(Html.Infragistics() .Grid(Model) .ID("grid") .PrimaryKey("id") .AutoGenerateColumns(false) .AutoGenerateLayouts(false) .LoadOnDemand(true) .Columns(column => { column.For(x => x.id).Hidden(true); column.For(x => x.email).HeaderText("Email Address").Width("20%").Template("<input type='button' data-id='${email}' onclick='SendResetPasswordEmail(this);' value='Reset'/> ${email}"); column.For(x => x.firstname).HeaderText("First Name").Width("20%"); column.For(x => x.lastname).HeaderText("Last Name").Width("30%"); column.For(x => x.typeid).HeaderText("Type").Width("5%").FormatterFunction("lookupUserTypes"); }) .Features(feature => { feature.Updating().EditMode(GridEditMode.RowEditTemplate).AddRowLabel("Add new User").RowEditDialogCaptionLabel("Edit User").ColumnSettings(cs => { cs.ColumnSetting().ColumnKey("email").Required(true).Validation(true); cs.ColumnSetting().ColumnKey("firstname").Required(true).EditorType(ColumnEditorType.Text); cs.ColumnSetting().ColumnKey("lastname").Required(true); cs.ColumnSetting().ColumnKey("typeid").EditorType(ColumnEditorType.Combo).Required(true).ComboEditorOptions(co => co.DataSource(northWindCategoriesJSON).ValueKey("typeid").TextKey("UserTypeName").Mode(ComboMode.DropDown).EnableClearButton(false)); }); feature.Sorting(); feature.Filtering(); feature.Paging(); }) .DataSourceUrl(Url.Action("GetUsers")) .ResponseDataKey(null) .UpdateUrl(Url.Action("UsersSaveData")) .DataBind() .Render())
Hello Ashwini,
You can add placeholder to the respective column editor through the editor options, for example:
cs.ColumnSetting().ColumnKey("email").TextEditorOptions(te=> {
te.PlaceHolder("email");
});
You can add email validation using regular expression through the validator options of the respective column, for example:
features.Updating().ColumnSettings(cs=>{
te.ValidatorOptions(v =>
{
v.Pattern("...", "error message");
If you need further assistance, please let me know.
Regards,
Tsanna
Hi Tsanna, Thanks for responding. But I get the following compilation errors when I try to use your recommendations. Please advice
'Infragistics.Web.Mvc.ColumnUpdatingTextEditorOptionsWrapper' does not contain a definition for 'PlaceHolder' and no extension method 'PlaceHolder' accepting a first argument of type 'Infragistics.Web.Mvc.ColumnUpdatingTextEditorOptionsWrapper' could be found (are you missing a using directive or an assembly reference?)
'Infragistics.Web.Mvc.EditorValidatorOptionsWrapper' does not contain a definition for 'Pattern' and no extension method 'Pattern' accepting a first argument of type 'Infragistics.Web.Mvc.EditorValidatorOptionsWrapper' could be found (are you missing a using directive or an assembly reference?)
Please note that these options are available from v15.2. Which version are you currently using?
Infragistics.Web.Mvc.dll version is 5.15.1.2352.
If these extensions are not available in that version, are there any other options to do validation & placeholder.
Hi,
Here is an example:
te.NullText("email");
v.RegExp("...");
Can you please provide me example of Validators for MVC Helper. All the examples that I saw are for jquery.
The equivalents for these options in 15.1 are:
- placeholder --> nullText
- pattern --> regExp
Please try them and let me know if you need further assistance.