user2405818
user2405818

Reputation: 55

Json value not getting binded to kendo dropdown

Im reading values from a javascript file. Im trying to bind a particular field into a kendo dropdown. i'm able to read the values but i could't assign them in the kendo dropdownlist.

var json = [
{
    "Type": "ABC",
    "Icon": "Ro.png"        
 }
},
{
    "Type": "DEF",
    "Icon": "Po.png",        
    }
}];

HTML :

   <select id="ListCurrencyDiv" class="testdiv"> </select>

Function:

  function BindValue() {
     $(".testdiv").kendoDropDownList({
    dataSource: {
        transport: {
            read: function (BindValue) {
                operation.success(json);
            }
        }
    },
    dataTextField: "Type",
    dataValueField: "Type",
    value: "No notification"
});}BindValue();

Upvotes: 0

Views: 797

Answers (1)

DontVoteMeDown
DontVoteMeDown

Reputation: 21465

First, fix your json object:

var json = [
{
    "Type": "ABC",
    "Icon": "Ro.png"        
},
{
    "Type": "DEF",
    "Icon": "Po.png",  
}];

Now that it becomes valid, try reading it directly in the dataSource option:

dataSource: json,

If this first demo from Kendo and your code are right, it should work.

Upvotes: 2

Related Questions