phphe / he-tree

Highly customizable draggable Vue.js tree component.
https://hetree.phphe.com/
233 stars 30 forks source link

Issue on fold and unfold, dropDisable options #117

Open MuthuSelviC opened 1 month ago

MuthuSelviC commented 1 month ago

In the testData array object, I added the open property. But It open all the nodes at initially. Also, I added disableDrop property. But I can drop the nodes.

<template>
    <div>Test tree
        <Draggable
            v-model="testData"
            treeLine>
            <template #default="{ node, stat }">
                <button @click="stat.open = !stat.open">
                    {{ stat.open ? '-' : '+' }}
                </button>
                {{ node.text }}
            </template>
        </Draggable>
    </div>
</template>

<script>
import {Draggable} from '@he-tree/vue';
import '@he-tree/vue/style/default.css';

export default {
    name       : 'TestTree',
    components : { Draggable },
    data () {
        return {
            testData   : [],
            selectedId : null
        };
    },
    mounted () {
        this.testData = [
            {
                id       : 1,
                text     : 'Item 1',
                open     : true,
                children : [
                    { id : 2, text : 'Child 1-1', open : false, disableDrop : true },
                    { id : 3, text : 'Child 1-2', open : false, disableDrop : true }
                ]
            },
            {
                id       : 4,
                text     : 'Item 2',
                open     : false,
                children : [
                    { id : 5, text : 'Child 2-1', open : false },
                    { id : 6, text : 'Child 2-2', open : false }
                ]
            }
        ];
    }
};
</script>

Anyone please check this issue. Could you tell me what I did wrong?

phphe commented 1 month ago

https://github.com/phphe/he-tree/blob/dev/packages/he-tree-vue/src/examples/Draggable.vue#L108

use statHandler to set initial properties

MuthuSelviC commented 1 month ago

Thanks. It works