Add a new item as First item after using DataSource...

2 posts, 0 answers
  1. Nicklas
    Nicklas avatar
    3 posts
    Member since:
    Jul 2013

    Posted 24 Aug 2013 Link to this post

    Im using the following code to read from a database, output to json and transfer to my Kendo UI Combobox.
    It works great. BUT i can´t figure out how to do add a special item that is first in the list and is selectable.
    I would like to add "No Project" and it should be selected as default. It should be on top of the list.

                   var project = $("#project").kendoComboBox({
                            filter: "contains",
                            height: 300,
                            //text: "No Project",
                            //value: "",
                            autoBind: false,
                            suggest: true,
                            highLightFirst: false,
                            placeholder: "Select project...",
                            dataTextField: "DBText",
                            dataValueField: "DBValue",
                            template: '<span class=\"comboList\">${ data.DBText }</span>',
                            change: ProjectonChange,
                            dataSource: {
                                type: "json",
                                serverFiltering: false,
                                transport: {
                                    read: "ListCustomers.cshtml?list=project&uid=@QueryUserId"
  2. Kiril Nikolov
    Kiril Nikolov avatar
    2598 posts

    Posted 27 Aug 2013 Link to this post

    Hello Nicklas,

    You can add an item to the dataSource binded to the ComboBox and then select this item. But this can be done after the dataSource is populated with the remote data. Using autoBind = false, makes the widget bind its dataSource when it is opened or something is typed inside the text box, so you will need to add the item after the dataSource is binded.

    Please check the following example showing a possible implementation:
    Kiril Nikolov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top