如何从Extjs 4.1中使用组件查询从组件获取插件? [英] How to get plugin from component using component query on Extjs 4.1?

查看:151
本文介绍了如何从Extjs 4.1中使用组件查询从组件获取插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Controller上添加事件监听器到插件。 http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Controller 使用组件查询获取插件似乎与普通组件不同。
是否可以使用组件查询从组件获取插件?

I want to add event listener to plugin on Controller.like http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Controller It seems different to get plugin using component query than normal component. Is it possible to get plugin from component using component query?

这是我的组件

Ext.define('App.view.file.List',{
     rootVisible: false, 
     extend:'Ext.tree.Panel',
     alias:'widget.filelist',
     viewConfig: {
        plugins: {
            ptype: 'treeviewdragdrop', 
            allowParentInsert:true 
        }
    },
    //etc ...

我可以得到 treeviewdragdrop 插件使用组件查询,如

Can i get treeviewdragdrop plugin using component query like

Ext.define('App.controller.FileManagement', {
    extend:'Ext.app.Controller',
    stores:['Folder'],
    views:['file.List','file.FileManagement'],
    refs:[
        { ref:'fileList', selector:'filelist' }
    ],
    init:function () {
        this.control({  
            'filelist > treeviewdragdrop':{drop:this.drop}  // <-- here is selector
        });
    },
    // etc ....


推荐答案

你不能因为插件不是组件,所以没有选择器会找到它。

You can't because a plugin is not a component, thus no selector will find it.

另外,drop事件被树视图触发,所以树视图真的是你想要挂钩的。

Also, the drop event is fired by the treeview, so the treeview is really what you want to hook to.

这将工作:

init:function () {
    this.control({  
        'filelist > treeview': {drop:this.drop}
    });
},

这篇关于如何从Extjs 4.1中使用组件查询从组件获取插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆