The goal is to be able to pass in a filtered data set to a listview that i can also type-and-find. I had the code working properly until i converted to a type-and-find (also known as a select2). Here's the code working without the pre-filtering.
@(Html.Kendo().DropDownList()
.Name(ViewData.TemplateInfo.HtmlFieldPrefix)
.DataTextField(TextField)
.DataValueField(ValueField)
.MinLength(3)
.ValuePrimitive(true)
.AutoBind(false)
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read => { read.Action("Get" + SrcTable + "s", "Support", readParams); });
})
.Virtual(v => v.ItemHeight(26))
.OptionLabel(OptionLabelText)
.Value(Model.ToString())
.HtmlAttributes(HtmlAttributes))
and here's working code to pre-filter.
@(Html.Kendo().DropDownList()
.Name(ViewData.TemplateInfo.HtmlFieldPrefix)
.DataTextField(TextField)
.DataValueField(ValueField)
.ValuePrimitive(true)
.AutoBind(false)
.DataSource(source =>
{
source.Read(read => { read.Action("Get" + SrcTable + "s", "Support", readParams)
.Data("filter" + ViewData.TemplateInfo.HtmlFieldPrefix);
})
.ServerFiltering(true);
})
.OptionLabel(OptionLabelText)
.Value(Model.ToString())
.CascadeFrom(cascade)
.HtmlAttributes(HtmlAttributes)
)
The .Data field is a hack javascript that gets the current value of what's in the control. It gets passed into the controller because we have "deactivated" items in the database and we want to show the current one if it is in an existing record but filter out the rest.
Now here's the problem: I can not combine these together. When i try, it breaks the typing search. Can anyone tell me why?
It looks like the problem was that you can't server-side filter a dataset that you want to type-and-find filter. I don't know why this would be an issue but it is. Setting .serverfiltering to false solved the problem.