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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

dialogTemplate validationRules for dropdownList

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hello,

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)) 
            </td>


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>")"
                                      value="@ViewBag.selectedEmployees">
                        <e-dropdownlist-fields validationRules="@(new { required=true})" text="EmployeeID" value="EmployeeID"></e-dropdownlist-fields>
                    </ejs-dropdownlist>

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. 
 
[index.cshtml] 
<script> 
    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 
            .  .  .  
        } 
} 
    } 
</script> 
 
 
Regards, 
Pavithra S. 


Blazej
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. 
  
Regards, 
Manivel 


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.

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