Initial Value When bound to Remote Data

3 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    55 posts
    Member since:
    Nov 2011

    Posted 01 Apr 2015 Link to this post

    Using pure jQuery, I have a ComboBox that retrieves values from a webservice.  How do I set the initial value such that it shows the name, and not the ID?

    For example I have 1 million customers in my database, but on page load I want to show that customer #17, Bob's Burgers, is currently selected.

    I'd like the combobox to initially show  [Bob's Burgers] and have a value of 17.

    Thanks in advance!


    var a = $(item).kendoComboBox({
           placeholder: "Select",
           dataTextField: "Name",
           dataValueField: "id",
           filter: "contains",
           autoBind: false,
           width: "400px",
           dataSource: {
               type: "json",
               serverFiltering: true,
               transport: {
                   read: {
                       type: 'POST',
                       url: "../WebServices/DropdownWebService.asmx/SearchCompanies",
                       item: item,
                       contentType: 'application/json; charset=utf-8',
                       datatype: 'json',
                       data: function (result) {
                           return {
                               ssid: globalValues.ssid,
                               query: result.filter?result.filter.filters[0]?result.filter.filters[0].value:"":"",
                               type: $(this.item).attr('data-type')
                           }
                       }
                   },
                   parameterMap: function (options) {
                       return JSON.stringify(options);
                   }
               },
               schema: {
                   data: "d"
               } // schema
           },
           template: '<span class="col-first"><span class="type-box-#: data.EntityType#">#: data.Name#</span></span>'
       });
  2. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 03 Apr 2015 Link to this post

    Hi Jeremy,

    Thank you for contacting Telerik support.

    You can use the DataBound event and the select method to select the desired item as in this example - http://dojo.telerik.com/@zdravkov/AMuDE.

    Regards,
    Plamen
    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
  4. Jeremy
    Jeremy avatar
    55 posts
    Member since:
    Nov 2011

    Posted 03 Apr 2015 Link to this post

    That looks to be exactly what I need. Thanks!

     

     

Back to Top