Reputation: 1480
I have a problem with missing data attributes in option after initialize kendo ui combobox.
My select look like this:
<select id="users">
<option value="1" data-message="OK1">User 1</option>
<option value="2" data-message="OK2">User 2</option>
</select>
now I create a kendo combobox based on this control:
$("#users").kendoComboBox({
change: function() {
alert($("#users option:selected").attr("data-message"));
}
});
and the result is "undefined".
The 'data-message' stored value is missing. Is there any way to store this information in combobox?
I've found similar question here: https://stackoverflow.com/questions/26769175/delete-stored-jquery-data-data-element-option-after-creating-a-kendo-combobox but still no answer.
Here is telerik dojo to test the code above: http://dojo.telerik.com/eyORO
Please help
Regards
Upvotes: 1
Views: 425
Reputation: 18402
That's actually a bit unusual since other widgets like the treeview keep their data attributes when created like that; anyway, your best option is to use a data source instead:
<input id="users" />
$("#users").kendoComboBox({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: "User 1", value: "1", message: "OK1" },
{ text: "User 2", value: "2", message: "OK2" }
],
change: function() {
console.log(this.dataItem().message);
}
});
Upvotes: 0