I am using ASP.NET MVC3, Jquery, and Kendo UI MVC Wrappers.
I have a simple Kendo UI drop down. It is a nullable drop down so I have the .OptionLabel property set to " ".
There are 2 scenarios when I load the page: 1.) The data for the drop down is supplied by the controller. 2.) The data for the drop down is not supplied by the controller in which case I am giving it an empty list
Upon the initial load of the page, the only available selection is the nullable option. The user can add more selections to the drop down by using other controls on the page.
When scenario #2 occurs, everything works perfectly fine. I get a drop down list with all of the selections and the null option. The items in the list come via my controller. The drop down works as expected.
When scenario #1 occurs. It seems like the drop down is not initializing or something like that. In this scenario I am sending an empty list from the controller. My expectation is that the drop down should have one selection which is the null option (because of my optionlabel), but instead I get a drop down that is in some sort of disabled state.
So in this situation, is passing an empty list to the drop down the right thing to do or should I be doing something else?
Here is the drop down declaration:
@(Html.Kendo().DropDownList()
.Name("allPeople")
.DataValueField("Id")
.DataTextField("Name")
.OptionLabel(" ")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("_SelectPeopleList", "People");
}).ServerFiltering(true);
})
.Events(e => e
.Change("all_change").Open("all_open"))
)
So just to reiterate, when I hit scenario #2, _SelectPeopleList is returning a list and everything works fine.
When I hit scenario #1, _SelectPeopleList is returning an empty list and the drop down gets in something similar to a disabled state.
Hopefully I was clear enough.