在extjs 4树中拖放一个节点

时间:2013-03-14 10:57:04

标签: php extjs extjs4

嗨,我是extjs 4的新手,我在树梢掉落时有问题,在drage和dropi中会丢弃叶子中的一个节点,叶子更改为文件夹,并且该叶子更改为drop节点的父节点

在我的代码下面

// Go ahead and create the TreePanel now so that we can use it below
var treePanel = Ext.create('Ext.tree.Panel', {
    id: 'tree-panel',
    title: 'Taxonomy',
    region: 'west',
    collapsible: true,
    split: true,
    multiSelect: true,
    height: '100%',
    width: '20%',
    minWidth: 100,
    rootVisible: false,
    autoScroll: true,
    store: store,
    viewConfig: {
        allowCopy: true,


        plugins: {
            ptype: 'treeviewdragdrop',
            appendOnly: true,
            ddGroup: 'selDD'
        },

        listeners: {
            beforedrop: function (node, data, overModel, dropPos, opts) {
                nodeval = data.records[0].data.text;
                //parent  = overModel.node.parentNode.id;
                this.droppedRecords = data.records;
                data.records = [];
            },
            drop: function (node, data, overModel, dropPos, opts) {
                var str = '';
                Ext.iterate(this.droppedRecords, function (record, node, data, dropPosition, dropFunction, parentNode) {
                    //  str += record.get('Patent_number') + ' (id = ' + record.get('Tech1') + ') dropped on ' +overModel.data.text + 'with id'+overModel.data.id+ '\n';
                    Ext.MessageBox.show({
                        title: 'Copy?,Drag/drop?',
                        msg: 'Do you wish to copy (or) drag/drop this node?',
                        buttons: {
                            ok: 'Copy',
                            no: 'Drag/drop',
                            cancel: 'Cancel'
                        },
                        buttonText: {
                            yes: "Copy",
                            no: "Drag/drop",
                            cancel: "Cancel"

                        },
                        fn: function (btn, text) {
                            if (btn == 'no') {
                                Ext.Ajax.request({
                                    url: 'json/dragedrop.php',
                                    method: "GET",
                                    params: {
                                        idFrom: treeID,
                                        idTo: overModel.data.id,
                                        taxo_id: '<?php echo $taxe_id;?>'
                                        //fromtext: data.records[0].data.text 
                                        //parentid:overModel.node.parentNode.id

                                    },
                                    success: function (response) {
                                        store.load();
                                    }
                                });

但上面的代码不起作用,drage节点不会掉落在叶子中,它会显示红色标记,

请建议并提供参考代码 提前谢谢

1 个答案:

答案 0 :(得分:0)

我认为这不是一个正确的答案,但这是这个问题的另一种逻辑

给定appendOnly:false,droped node parent的插件中的

hover nodehover node更改为droped节点的parent的时间

我认为它仅在某些时候使用