- Home
- Forum
- ASP.NET MVC
- Customize validation message (Inline editing)
Customize validation message (Inline editing)
Hello,
I would like to customize the required field message which is shown when the user tries to save during grid inline editing.
In the example below I set the grid's Locale to "pt-BR" but the DropDown column "ResourceRate" keeps showing the default english message (e. g. Rate is required) whenever I try to save.
@(Html.EJ().Grid<ETCPlanMaoDeObraViewModel>("GridMaoDeObra")
.Datasource(ds => ds.Json((IEnumerable<ETCPlanMaoDeObraViewModel>)Model.MaoDeObra)
.UpdateURL(Url.Action("GridMaoDeObraUpdate", "ETCPlan"))
.InsertURL(Url.Action("GridMaoDeObraInsert", "ETCPlan"))
.RemoveURL(Url.Action("GridMaoDeObraDelete", "ETCPlan"))
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit =>
{
edit.AllowAdding()
.AllowDeleting()
.AllowEditing()
.ShowDeleteConfirmDialog(true);
})
.Locale("pt-BR")
.AllowPaging()
.Columns(col =>
{
col.Field("Id").IsPrimaryKey(true).IsIdentity(true).Visible(false).Add();
col.Field("ResourceName").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Name).Width(90).EditType(EditingType.Dropdown)
.DataSource(Model.ResourceNames).Add();
col.Field("ResourceRE").Visible(false).Add();
col.Field("WBSCode").Visible(false).Add();
col.Field("ResourceRate").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Rate).Width(60).EditType(EditingType.Dropdown)
.DataSource(Model.Rates).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field("JanValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Jan).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("FebValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Feb).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("MarValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Mar).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("AprValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Apr).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("MayValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_May).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("JunValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Jun).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("JulValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Jul).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("AugValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Aug).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("SepValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Sep).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("OctValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Oct).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("NovValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Nov).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
col.Field("DecValue").HeaderText(Resource.ETCPlan_SpendPlanTabMaoDeObra_GridHeader_Dec).Width(50).EditType(EditingType.String).AllowEditing(false).Add();
})
)
Thanks in advance.
SIGN IN To post a reply.
3 Replies
KK
Karthick Kuppusamy
Syncfusion Team
September 6, 2016 01:15 PM UTC
Hi Fernando,
Thanks for Contacting Syncfusion Support.
We have analyzed your requirement and we can customize the validation rules based on the culture.
Please find the code example.
|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowScrolling()
.AllowPaging() /*Paging Enabled*/
.SelectionType(SelectionType.Single)
.Locale("pt-BR")//Localization
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
items.AddTool(ToolBarItems.WordExport);
items.AddTool(ToolBarItems.PdfExport);
}))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").ValidationRules(v => v.AddRule("required", true).AddRule("messages", "{required:'requeridos'}")).TextAlign(TextAlign.Right).Width(75).Add();//Validation rule in Portuguese language
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();
col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy}").Add();
}))
|
For your reference we have created a sample based on your requirement and same it can be downloaded from the following location.
If we misunderstood your requirement then could you please share more details about your requirement it would be helpful for us to find the solution as earliest.
Regards,
K.Karthick.
FE
Fernando
September 12, 2016 11:36 AM UTC
Thanks, it works fine!
Could you link me the "ValidationRules.AddRule" documentation? It would be really helpful to have all the customization options (e.g. "required", "messages", etc)
VA
Venkatesh Ayothi Raman
Syncfusion Team
September 13, 2016 05:13 AM UTC
Hi Fernando,
Thanks for the update.
We are happy to hear that your requirement is achieved. Please refer to the below Help documentation for more information,
Regards,
Venkatesh Ayothiraman.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
FE Fernando
- Sep 5, 2016 04:30 PM UTC
- Sep 13, 2016 05:13 AM UTC