@Html.EJ().DropDownListFor(model => model.ProviderId, new DropDownListProperties()
{
DataSource = Model.Providers,
DropDownListFields = new DropDownListFields() { Text = "Name", Id = "Id", Value = "Id" },
ValidationRules = new Dictionary<string, object> { { "required", true } },
ValidationMessage = new Dictionary<string, object> { { "required", ModelResource.ProviderErrorMessage } },
WatermarkText = "Select a provider",
Enabled = Model.EnableAllFields,
Width = "100%"
})
When the dialog is open, no item is selected in the drop-down, even if the ProviderId in the Model has a value.
Also, the validators are no longer working, they are not triggered even if I'm not selecting an item before submitting the form. I am currently including the file 'ej.unobtrusive.min.js'. do I have to include other files?
I have recent;y updated the syncfusion controls to the latest version (14.1400.0.46). Before the update, there was no problem with these controls.
Thank you!
Query |
Solution | |
1. When the dialog is open, no item is selected in the drop-down, even if the ProviderId in the Model has a value. |
We suggest you to use selectedIndex property to make an item selected in dropdown when dialog is open.
<code>
@Html.EJ().DropDownListFor(model=>model.providers, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).WatermarkText("Select a Provider").SelectedIndex(2)
</code>
| |
2. the validators are no longer working, they are not triggered even if I'm not selecting an item before submitting the form. I am currently including the file 'ej.unobtrusive.min.js'. do I have to include other files? |
We suggest you to refer jquery.validate.min.js and jquery.unobtrusive.min.js in script section.
In our previous versions jquery validation will work fine .After 14.1 the input element was hidden in DropDownList so jquery will not validate the hidden element. So we have to configure validator settings manually.We have prepared a sample for validation
Please refer the sample link:
|
$.validator.setDefaults({
//to validate all fields(hidden also)
ignore: [],
//if we don’t set custom class, default “error” class will be added
errorClass: 'e-validation-error',
//it specifies the error message display position
errorPlacement: function (error, element) {
$(error).insertAfter(element.closest(".e-widget"));
}
}); |
@Html.EJ().DropDownListFor(model=>model.providers, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).WatermarkText("Select a Provider").Value("Austin-žHealey")
|