extjs 4拖放问题

发布于 2024-11-30 08:09:26 字数 4350 浏览 1 评论 0原文

我试图拖动嵌套在作为视口一部分的面板中的面板。我想将它放在一个单独的面板上,该面板是视口的一部分。我尝试过添加侦听器、设置 dropallowed 以及其他一些在线示例,但似乎对我不起作用。这是我的代码。我希望能够抓住任何一个“图标”面板并将它们拖动到“我的工作区”面板。我不需要渲染拖动到拖放区的项目。我只想在事件发生时触发一个函数。

var MySites = new Ext.application({
    name: 'MySites Application',
    launch: function () {
        Ext.create('Ext.Viewport', {
            title: 'My Center',
            layout: 'border',
            items: [{
                xtype: 'panel',
                region: 'west',
                collapsible: true,
                collapsed: true,
                title: 'Applications',
                width: 250,
                layout: 'accordion',
                margins: '5 0 0 5',
                defaults: {
                    bodyStyle: 'padding:15px'
                },
                layoutConfig: {
                    // layout-specific configs go here
                    titleCollapse: false,
                    animate: true,
                    activeOnTop: true
                },
                items: [{
                    title: 'Apps',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }, {
                    title: 'Favorites',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }, {
                    title: 'Reporting',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }]
            }, {
                title: 'My Workspace',
                region: 'center',
                xtype: 'panel',
                layout: 'fit',
                margins: '5 5 0 0'
            }, {
                title: 'Tasks',
                region: 'south',
                height: 300,
                split: true,
                xtype: 'panel',
                collapsible: true,
                collapsed: true,
                margins: '0 5 5 5',
                html: 'Item 1<br />Item 2<br />Item 3'
            }],
            renderTo: Ext.getBody()
        })
    }
});

Im trying to drag a panel that is nested in a panel that is part of a viewPort. I want to drop it on a separate panel that is part of the viewPort. I have tried adding listeners, setting dropallowed, and some other online examples but nothing seems to work for me. Here is my code. I want to be able to grab any one of the "icon" panels and drag them over to the "My Workspace" panel. I dont need to render the item im dragging to the dropzone. I just want to fire off a function when the event takes place.

var MySites = new Ext.application({
    name: 'MySites Application',
    launch: function () {
        Ext.create('Ext.Viewport', {
            title: 'My Center',
            layout: 'border',
            items: [{
                xtype: 'panel',
                region: 'west',
                collapsible: true,
                collapsed: true,
                title: 'Applications',
                width: 250,
                layout: 'accordion',
                margins: '5 0 0 5',
                defaults: {
                    bodyStyle: 'padding:15px'
                },
                layoutConfig: {
                    // layout-specific configs go here
                    titleCollapse: false,
                    animate: true,
                    activeOnTop: true
                },
                items: [{
                    title: 'Apps',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }, {
                    title: 'Favorites',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }, {
                    title: 'Reporting',
                    layout: 'auto',
                    items: [{
                        xtype: 'panel',
                        title: 'Icon 1',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 2',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }, {
                        xtype: 'panel',
                        title: 'Icon 3',
                        height: 75,
                        width: 75,
                        padding: '5 5 5 5',
                        draggable: true
                    }]
                }]
            }, {
                title: 'My Workspace',
                region: 'center',
                xtype: 'panel',
                layout: 'fit',
                margins: '5 5 0 0'
            }, {
                title: 'Tasks',
                region: 'south',
                height: 300,
                split: true,
                xtype: 'panel',
                collapsible: true,
                collapsed: true,
                margins: '0 5 5 5',
                html: 'Item 1<br />Item 2<br />Item 3'
            }],
            renderTo: Ext.getBody()
        })
    }
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文