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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

dialogTemplate validationRules for dropdownList

Thread ID:





145002 May 31,2019 02:37 PM UTC Jun 5,2019 04:35 AM UTC ASP.NET Core - EJ 2 3
Tags: DataGrid
Asked On May 31, 2019 02:37 PM UTC


I need add validationRules for dropdownList in grid dialogtemplate.
I found similar but for ASP.NET MVC here: https://www.syncfusion.com/forums/139118/editmode-dialogtemplate-with-ejdropdownlist-validation

<td style="text-align: left"> 
                @Html.EJ().DropDownListFor(o => o.EmployeeID, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewBag.ddl).DropDownListFields(o=>o.Text("id").Value("id")).ValidationRules(v=>v.AddRule("required", true)) 

I have:

<ejs-dropdownlist width="200" id="EmployeeID" dataSource="@ViewBag.Employees" filtering="onfiltering" placeholder="Wybierz Pracownika" allowFiltering="true" filterBarPlaceholder="Wyszukaj"
                                      headerTemplate="@Html.Raw("<div class=\"header\"> Imię i Nazwisko</span></div>)")"
                                      itemTemplate="@Html.Raw("<div class=\"name\"> ${Name} ${Surname} </div>")"
                                      valueTemplate="@Html.Raw("<div class=\"name\"> ${Name} ${Surname} </div>")"
                        <e-dropdownlist-fields validationRules="@(new { required=true})" text="EmployeeID" value="EmployeeID"></e-dropdownlist-fields>

I need to validate if dropdownlist is selected from list. Default is null. I want to prevent close dialog if dropdownlist is not selected.
Flag validationRules don't work here.

In Grid when i add:

<e-grid-column validationRules="@(new { required=true})" allowEditing="false" field="EmployeeID" width="80" headerText="EmployeeID" visible="false"></e-grid-column>

don't work too. Works only for input text.

Pavithra Subramaniyam [Syncfusion]
Replied On June 4, 2019 11:12 AM UTC

Hi Blazej, 
Thanks for contacting Syncfusion support. 
You have disabled the “visible” property of EmployeeID column so the form validation is not applied to that column. However you can achieve your requirement by adding the validation rule for “employeeID” column in the actionComplete event. Please refer to the below code example and documentation link for more information. 
    function actionComplete(args) { 
        if ((args.requestType === 'beginEdit' || args.requestType === 'add')) { 
            // Add Validation Rules 
            args.form.ej2_instances[0].addRules('EmployeeID', { required: true }); 
        if (args.requestType === 'beginEdit') { 
           // send ajax for edit partial 
            .  .  . 
        if (args.requestType === 'add') { 
          // send ajax for add partial 
            .  .  .  
Pavithra S. 

Replied On June 4, 2019 01:22 PM UTC

Great!. Thank you. It work!

Manivel Sellamuthu [Syncfusion]
Replied On June 5, 2019 04:35 AM UTC

Hi Blazej, 
Thanks for your update. 
We are happy to hear that your problem has been resolved. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon