Answer the question
In order to leave comments, you need to log in
vue-treeselect plugin. With Delayed Loading, Children are loaded but not displayed. What could be the problem?
I'm using the vue-treeselect plugin to display a tree of regions from Google.
To load subregions (children) I use the Delayed Loading method.
According to the documentation, I did the following steps:
1. Set children: null for non-loadable data:
mounted() {
this.regionsRoot[0].children.map((obj) => {
obj.children = null;
return obj;
});
}
<div class="regions-container">
<treeselect
v-model="geoLocal"
:load-options="loadOptions"
:options="regionsRoot"
:normalizer="normalizer"
:multiple="true"
:placeholder="place"
:no-results-text="noResults"
:is-default-expanded="true"
:default-expand-level="1"
:always-open="true"
:search-nested="true"
:max-height="360"
:loading-text="loadingText"
/>
</div>
loadOptions({ action, parentNode, callback }) {
console.log(parentNode);
if (action === LOAD_CHILDREN_OPTIONS) {
axios('/google_regions/?node=' + parentNode.key, {
method: 'GET',
})
.then((data) => {
console.log(data);
parentNode.children = data.data;
console.log(parentNode.children);
callback();
})
.catch((error) => {
callback(new Error('Failed to load options: network error.'));
});
}
normalizer(node) {
return {
id: node.key,
label: node.title,
};
},
Answer the question
In order to leave comments, you need to log in
You have a jamb with reactivity somewhere. There is a suspicion that when assigning obj.children = null; obj doesn't have a children key - vue doesn't keep track of it. Use $set when mapping obj. Show what is in this.regionsRoot[0], or better yet, write an example in JSFiddle
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question