Input validation in iggrid
New DiscussionExist there any option to easily validate the values changed in an igGrid? For example, if my model contains a "description" field with a maximum length of 50, so that in the grid I only can insert 50 characters (or an error message occurs).
For single editor controls I found this: http://igniteui.com/editors/data-annotation-validation
Such validation I need for the iggrid, exists there anything?
Simple example of my model:
public class SubTopicLocal
{
[Required]
public int SubTopicID { get; set; }
[StringLength(10, ErrorMessage = "Error message abc …")]
public string Description { get; set; }
}
Simple example of my View:
@(Html.Infragistics()
.Grid(Model)
.ID("grid")
.Height("100%")
.Width("100%")
.AutoGenerateColumns(false)
.AutoGenerateLayouts(false)
.RenderCheckboxes(true)
.PrimaryKey("SubTopicID")
.TemplatingEngine(GridTemplatingEngine.JsRender)
.Columns(column =>
{
column.For(x => x.SubTopicsLocalCopy.First().SubTopicID).HeaderText("SubTopic ID");
column.For(x => x.SubTopicsLocalCopy.First().Description).HeaderText("Description");
})
.Features(feature =>
{
feature.Updating().ColumnSettings(cs =>
{
cs.ColumnSetting().ColumnKey("SubTopicID").ReadOnly(true);
cs.ColumnSetting().ColumnKey("Description").Required(true).Validation(true);
});
feature.Sorting();
…
…
})
.DataSourceUrl(Url.Action("GetSubTopicsLocal"))
.UpdateUrl(Url.Action("SubTopicLocalSaveData"))
.DataBind()
.Render()
)
As like in the posted link, I need that by editing the (for example) "description", the iggrid validate the input, in this case that the length is smaller than 50. How can I do this? Analog to the validation with:
@Html.ValidationMessageFor(x => x.Description, "", new { @class = "text-danger" })