Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 4.1检查更改侦听器_Extjs_Extjs4.1 - Fatal编程技术网

Extjs 4.1检查更改侦听器

Extjs 4.1检查更改侦听器,extjs,extjs4.1,Extjs,Extjs4.1,处理菜单检查项事件的正确方法是什么 我有这个菜单: { xtype: 'button', id: 'types_btn', autoWidth: true, text: 'Types', menu: { xtype: 'menu', frame: true, id: 'types_menue', items: [

处理菜单检查项事件的正确方法是什么

我有这个菜单:

 {
      xtype: 'button',
      id: 'types_btn',
      autoWidth: true,
      text: 'Types',
      menu: {
              xtype: 'menu',
              frame: true,
              id: 'types_menue',

              items: [
                       {
                         xtype: 'menucheckitem',
                         id: 'f_type',
                         text: 'first',
                         listeners: {
                            checkchange: {
                                    fn: me.onFirstButtoncheckchange,
                                    scope: me
                                    }
                                      }
                       },
                       {
                        xtype: 'menucheckitem',
                        id: 's_type',
                    text: 'second',
                         listeners: {
                            checkchange: {
                                    fn: me.onSecondButtoncheckchange,
                                    scope: me
                                    }
                                      }
                       }
然后,功能:

onFirstButtoncheckchange: function(menucheckitem, checked, options) {

    var t = Ext.getCmp('f_type');
               if (t.checked)
                   goToFunction(???);
                 .
                 .
    },
 onSecondButtoncheckchange: function(menucheckitem, checked, options) {

    var t = Ext.getCmp('s_type');
               if (t.checked)
                   goToFunction(???);
                 .
                 .
    },
1-是否仍然可以使用一个侦听器并在其中收集所有不同的函数


2-如何将当前项发送到goToFunction(),如代码中所示?

只需为每个菜单检查项创建一个处理程序:

items: [{
    xtype: 'menucheckitem',
    text: 'select all' ,
    id: 'first' ,
    listeners: {
        checkchange: me.myHandler
    }
},{
    xtype: 'menucheckitem',
    text: 'select specific' ,
    id: 'second' ,
    listeners: {
        checkchange: me.myHandler
    }
}]
您的处理程序定义如下:

myHandler: function (menucheckitem, checked, opts) {
    switch (menucheckitem.getId ()) {
        // Here handles the first
        case 'first':
            if (checked) {
                console.log ('First checked!');
                goToFunction ();
            }
            break;
        // Here handles the second
        case 'second':
            if (checked) {
                console.log ('Second checked!');
                goToFunction ();
            }
            break;
        default:
            console.log ('Whatever!');
    }
}

看起来侦听器不太经常被触发。您可以改为使用checkHandler配置