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

list values are not displaying in kendoComboBox

2 Answers 177 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
shankar parshimoni
Top achievements
Rank 1
shankar parshimoni asked on 29 Nov 2012, 06:22 AM
i want to bind list of values to kendoCombobox from dataBase through webservices.here is the code
  

<select id = "CbxArea" style="width:200px">
</select>

$(document).ready(function () 
$("#CbxArea").kendoComboBox();       
var cmbArea = $("#CbxArea");        
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "FlashReportWebService.asmx/GetAreaNames",
dataType: "json",
success: function (data) {
for (i = 0; i < data.d.length; i++) {
cmbArea.append($("<option></option>").val(data.d[i].AreaName).html(data.d[i].AreaName));
}
}
});


list of values are coming successfully, but the problem is only 1st value is showing in combobox,remaining values are not displaying(i have 16 values in list)
if i write $("#CbxArea"); instead of $("#CbxArea").kendoComboBox(); total 16 values are displaying in comboBox.is there any problem in kendocombobox for binding values from .asmx page....i must display values in kendoComboBox only...please help..
thanks,
parsanamoni.

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 29 Nov 2012, 08:31 AM
Hello,

 Adding options to the element from which the combobox is created won't work. You need to initialize the combobox after the server response is received:

<select id = "CbxArea" style="width:200px">
</select>

$(document).ready(function () 
        var cmbArea = $("#CbxArea");        
       
        $.ajax({
              type: "POST",
              contentType: "application/json; charset=utf-8",
              url: "FlashReportWebService.asmx/GetAreaNames",
              dataType: "json",
              success: function (data) {
                  for (i = 0; i < data.d.length; i++) {
                       cmbArea.append($("<option></option>").val(data.d[i].AreaName).html(data.d[i].AreaName));
                  }
            // create combobox after data is received
           $("#CbxArea").kendoComboBox();       
         }
});



Greetings,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
shankar parshimoni
Top achievements
Rank 1
answered on 30 Nov 2012, 05:10 AM
Hi AtanasKorchev

awesome answer,its working fine.thanks for your support.

Regards,
parsanamoni
Tags
ComboBox
Asked by
shankar parshimoni
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
shankar parshimoni
Top achievements
Rank 1
Share this question
or