We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Customize validation message (Inline editing)

Thread ID:

Created:

Updated:

Platform:

Replies:

125708 Sep 5,2016 04:30 PM UTC Sep 13,2016 05:13 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Fernando
Asked On September 5, 2016 04:30 PM UTC

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.

Karthick Kuppusamy [Syncfusion]
Replied On 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. 
 


Fernando
Replied On 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)

Venkatesh Ayothi Raman [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;