Hello, the following code works like a charm:
var arr = [ {text:"Option 11",value:"Value 11"}, {text:"Option 22",value:"Value 22"} ]; arr.push({text:"Option 33",value:"Value 33"}); var datasource = new kendo.data.DataSource({ data: arr }); datasource.read(); jQuery("#operation").data("kendoDropDownList").setDataSource(datasource);
However if I try this:
var arr = [ {text:"Option 11",value:"Value 11"}, {text:"Option 22",value:"Value 22"} ]; for(i=0;i<operators.length;i++) { var singleElement = { text:operators[i], value:operators[i] }; arr.push(singleElement); } var datasource = new kendo.data.DataSource({ data: arr }); datasource.read(); jQuery("#operation").data("kendoDropDownList").setDataSource(datasource);
I get [object Object] where I should have the elements
of operators as values and text on the dropdownlist.
If I try this:
var arr = [ {text:"Option 11",value:"Value 11"}, {text:"Option 22",value:"Value 22"} ]; for(i=0;i<operators.length;i++) { var singleElement = "{text:\""+operators[i]+",value:\""+operators[i]+"\"}"; arr.push(singleElement); } var datasource = new kendo.data.DataSource({ data: arr }); datasource.read(); jQuery("#operation").data("kendoDropDownList").setDataSource(datasource);
I get "undefined" where I should have the elements
of operators as values and text on the dropdownlist.
Any idea on how can get the values from "operators" into the datasource and show up on the dropdownlist ?
Thanks,
Rafael