The avalonjs tree component cannot get the expected data after recursive rendering

problem description

after the recursive display of the

tree component, the checked data cannot be obtained normally (same as duplex invalidation)

the environmental background of the problems and what methods you have tried

want to automatically store the checked data in the array in the form of duplex duplex. In other demo, no problem, but in the tree (through recursive: html), invalidation

related codes

/ / define a component
< ms-tree: widget= "{url: @ url, showCheck: true, onReady: treeReady}" > < / ms-tree >
/ / below is the component"s html

    <li :for="(@index, @el) in @tree">
        <input type="checkbox" ms-attr="{value:@el.id}" data-duplex-changed="@selectOneFun(@el)" ms-duplex="@selected"/>
        <span :click="@openSubTree(el)" :class="[changeIcon(el)?"floder":"file"]"></span>
        {{el.name}}
        <div :visible="@el.open" :html="@renderSubTree(@el)">
        </div>
    </li>


/ / all checked data stores the node"s id in the selected array. Each check operation calls the selectOneFun method
/ / the following is the basic method
/ / select
getSelected: function () {

alert(this.selected)
return this.selected

},
selectOneFun: function (e) {

alert(e.id)
// push,getSelected
// this.selected.push(e.id)

},
renderSubTree: function (el) {

return "<ms-tree :widget="{tree: @el.subTree}"></ms-tree>"

}

what result do you expect? What is the error message actually seen?

every time it is checked, you can get all the checked node id values through the getSelected method, but only the first node can get it, and none of the other nodes (generated by recursion) can get it, even if it is directly push into the selected, the getSelected method cannot get it. I thought it was very strange. I hope the god can give me some advice and bring a screenshot

clipboard.png

clipboard.png

clipboard.png

Apr.04,2021
Menu