I am using Vuejs 2.x.
I am trying to use the dropdowntree to display a large hierarchy.
I am also trying to use the ValueMapper to pre load the checked items.
The problem I have is that the valueMapper is not being called until I start clicking on nodes.
How to I get the valueMapper to check the correct nodes when the page is rendered?
Here is my code:
<body>
<input id="dropdowntree">
<script>
$(document).ready(function () {
var localData = [
{ id: 1, text: "Parent 1", items: [
{ id: 2, text: "Child 1.1" },
{ id: 3, text: "Child 1.2" }
]},
{ id: 4, text: "Parent 2", items: [
{ id: 5, text: "Child 2.1" },
{ id: 6, text: "Child 2.2" }
]}
];
var dropDownTree = $("#dropdowntree").kendoDropDownTree({
placeholder: "Select an item...",
dataSource: {
data: localData,
schema: {
model: {
id: "id",
children: "items",
fields: {
id: { type: "number" },
text: { type: "string" }
}
}
}
},
loadOnDemand: {
//THIS IS NOT CALLED UNTIL I START CLICKING NODES
valueMapper: function (options) {
var value = options.value;
var item = localData.find(function (dataItem) {
return dataItem.id == value;
});
options.success(item ? [item.id] : []);
}
},
dataTextField: "text",
dataValueField: "id",
//value: [2,5], //SETTING THIS DID NOT HELP
checkboxes: true,
checkAll: true,
autoClose: false
});
dropDownTree.value = [5]; // Trying to manually set value and call the valuemapper
});
</script>
</body>