I have a grid with a pop-up edit form, with a cascading dropdown list. It works fine except that when choosing to add a new record, the form opens and the dropdown list shows the validation error message before the user has done anything.
I've attached a screenshot. The definition of the dropdown lists is:-
<p>
<span class=
"fieldlabel"
>
System:
</span>
@(Html.Kendo().DropDownListFor(m => m.system)
.Name(
"system"
)
.OptionLabel(
"Select a system"
)
.DataValueField(
"Code"
)
.DataTextField(
"Description"
)
.DataSource(src => src.Read(rd => rd.Action(
"GetSystems"
,
"Home"
)))
)
@Html.ValidationMessageFor(model => model.system)
</p>
<p>
<span class=
"fieldlabel"
>
Priority:
</span>
@(Html.Kendo().DropDownListFor(m => m.Priority)
.Name(
"Priority"
)
.OptionLabel(
"Select a priority"
)
.DataValueField(
"Code"
)
.DataTextField(
"Description"
)
.DataSource(src => src.Read(rd => rd.Action(
"GetPriorities"
,
"Home"
)))
)
@Html.ValidationMessageFor(model => model.Priority)
</p>
<p>
<span class=
"fieldlabel"
>
Sub Category:
</span>
@(Html.Kendo().DropDownListFor(m => m.SubCategoryCode)
.Name(
"SubCategoryCode"
)
.OptionLabel(
"Select a sub category"
)
.DataValueField(
"Code"
)
.DataTextField(
"Description"
)
.DataSource(src => src.Read(rd => rd.Action(
"GetSubCategoriesbySystem"
,
"Home"
).Data(
"filterSystems"
)).ServerFiltering(
true
))
.Enable(
false
)
.AutoBind(
false
)
.CascadeFrom(
"system"
)
)
@Html.ValidationMessageFor(model => model.SubCategoryCode)
</p>
How can I stop this?
Thanks
12 Answers, 1 is accepted
We have a code library that covers the cascading DropDownLists in the Grid's popup editor scenario. I tested it with version 2016.2.714 and a validation message was not displayed on popup opening, but after clicking on a DropDownList. Could you please run it, try to reproduce the behavior you are experiencing it it and attach it for further review?
Looking forward to your reply.
Regards,
Ivan Danchev
Telerik by Progress
Thanks for this. I got the library code to run, and it was fine. I then transferred the classes and page over to my project, and got some very strange behaviour.
1. A record could be saved without any validation firing, if all the dropdowns were left untouched.
2. As soon as the first drop-down was clicked, all validation messages fired (screenshot attached).
I'm using Version 2016.2.504 of KendoUI, Version 4.5 of the .NET framework and MVC 5.
We were able to reproduce the behavior you describe. It seems a change has been introduced to the validation logic since Q1 2016, because the validation triggers differently if version 2015.3.930 scripts are used compared to using 2016.1.112 and newer. We will need more time, in order to further investigate this inconsistency. I will get back to you as soon as we have any result.
Regards,
Ivan Danchev
Telerik by Progress
Thank you for your patience.
The behavior in the latest version is identical to the one in Q1 2016 and newer releases. We logged a public issue that contains more information.
Regards,
Ivan Danchev
Telerik by Progress
As a token of gratitude for your involvement in identifying this issue I updated your Telerik points.
Regards,
Ivan Danchev
Telerik by Progress
Looking at the GitHub issues page, this issue appears to have been closed and not fixed. Is this the case?
This is quite concerning, as this will prevent us using the latest versions of Kendo UI.
The issue log states the behaviour is 'unintuitive', however I would say that it is just plain broken, as its not what a user expects when starting to enter a new record.
Indeed the issue has been reviewed and closed after the team decided that this is the expected behavior, as explained by ggkrustev in his comment on the issue.
Regards,
Ivan Danchev
Telerik by Progress
Unfortunately, it's the expected behaviour for developers using MVVM, not users, who on going to enter a new record are immediately faced with validation warnings.
The suggested workaround of using nullable fields removes the point of validation (which in the case of a drop-down lists is to ensure a value is selected).
Cascading drop-down lists worked well until the 2016 release, and now are unusable. I would urge you to think again, and revisit this behaviour, as at the moment there is no point upgrading or starting development on new projects using any version of Kendo UI later than 2015 Q3.
At the very least, is it possible for you to provide details on how to remove the MVVM functionality that's causing the problem from later versions, so I can keep up to date, but keep using cascading drop-downs.
We appreciate your feedback. I forwarded it to the dev team along with your inquiry on the MVVM functionality and will get back to you as soon as I receive any new information.
Regards,
Ivan Danchev
Telerik by Progress
I received a word from our developers and a change in the way validation is triggered currently is not planned.
Thus the options for keeping the old behavior are:
- you can use the Kendo UI version that has the desired behavior and not upgrade to a newer version
- you can modify the relevant code, in order to achieve the expected behavior
- you can create your own implementation of DropDownList cascade different from the built-in one
Regards,
Ivan Danchev
Telerik by Progress