I am apparently missing something in setting up a combo box, can someone help me out?
I followed the examples, and got to here:
------
public JsonResult GetItems(string filter)
{
List<Item> Items = new List<Item>();
if (!string.IsNullOrEmpty(filter))
using (ScratchDBClassesDataContext DB = new ScratchDBClassesDataContext())
Items = DB.Items.Where(itm => itm.Name.Contains(filter)).ToList();
return Json(Items, JsonRequestBehavior.AllowGet);
}
------
@(Html.Kendo().ComboBox()
.Name("ItemCombo")
.DataSource(ds =>
{
ds.Read(read =>
{
read.Action("GetItems", "Home").Data("FilterValue");
});
ds.ServerFiltering(true);
})
.DataTextField("Name")
.DataValueField("ItemID")
.AutoBind(false)
.MinLength(3)
.ClearButton(true)
)
<script>
function FilterValue() {
var ItemCombo = $("#ItemCombo").data("kendoComboBox");
return { filter: ItemCombo.text() };
}
</script>
------
It works initially - once I type 3 characters, the read action runs and my initial results are shown in the popup. However, after that, the read action never fires again when I continue typing, so the box never further filters my results.
I put a breakpoint in my controller code as well as an alert in the "FilterValue" function, and I can confirm that the action is not firing.
I discovered that if I add ".Filter(FilterType.Contains)" to the combobox configuration, the action fires every time I type after the 3rd character but my controller receives a null value for the filter string. An alert in "FilterValue" shows that ItemCombo.text() has the value I want, but it isn't being sent to the controller.
What have I missed here?