This is a migrated thread and some comments may be shown as answers.

dynamically populate combobox

1 Answer 464 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 01 Aug 2014, 07:04 AM
I'm trying to dynamically populate a combobox as the user types, however, once the combobox has done the first data fetch (i.e. minLength: 3) it does not fire again if the user hits backspace a few times and types in a new phrase.

How is this dynamically server filtering possible?

My setup:

var userDs = new kendo.data.DataSource({
    transport: {
        read: {
            type: "POST",
            url: '@Url.Action("GetUsers", "System")',
            data: function() {
                return {
                    filter: $("#user").data("kendoComboBox").input.val()
                }
            },
            dataType: "json",
            contentType: "application/json; charset=utf-8"
        },
        parameterMap: function(data, type) {
            return kendo.stringify(data);
        }
    }
});


$("#user").kendoComboBox({
    template: '<div>#:data.name# (#:data.role#, #:data.country#)</div>',
    dataSource: userDs,
    autoBind: false,
    dataTextField: "name",
    dataValueField: "id",
    minLength: 3,
    placeholder: "Select user...",
});


public JsonResult GetUsers(string filter)
{
    List<object> result = new List<object>();
    ...
    return Json(result);
}

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Aug 2014, 09:14 AM
Hello Morten,

You will need to enable the server filtering setting the data source serverFiltering option to true. Check this online demo for more information.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ComboBox
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Georgi Krustev
Telerik team
Share this question
or