dynamically populate combobox

2 posts, 0 answers
  1. Morten
    Morten avatar
    267 posts
    Member since:
    Jul 2012

    Posted 01 Aug 2014 Link to this post

    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);
    }
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 01 Aug 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top