sencha无法在控制器中触发我的标签显示事件

时间:2015-08-19 09:02:42

标签: javascript extjs sencha-touch-2

我遇到了一个问题,因为我不能在我看来启动我的控制器功能,因为它只是一个提醒演示。

我的控制员:

Ext.define('ylp2p.controller.viewdata',{
    extend: 'Ext.app.Controller',
    config: {
        control: {
            viewlabel: {
                show: 'viewlabelFn'
            }
        },        
        refs: {
            viewlabel: 'label[id=datalabel]',
        }
    },    
    viewlabelFn: function(){
        alert('painted');
    }
});

我的观点:

Ext.define('ylp2p.view.Main', {
    extend: 'Ext.tab.Panel',
    xtype: 'main',
    requires: [
        'Ext.TitleBar',
        'Ext.carousel.Carousel',
        'ylp2p.store.datainterests',
    ],
    config: {
        fullscreen: true,
        tabBarPosition: 'bottom',
        scrollable: 'vertical',
        items: [
            {
                title: '首页',
                iconCls: 'home',
                styleHtmlContent: true,
                scrollable: true,
                layout: 'card',
                items:  [
                {
                    docked: 'top',
                    xtype: 'titlebar',
                    title: 'ylp2p'
                },
                {
                    xtype: 'container',
                    layout: 'vbox',
                    items:[
                        {
                            xtype: 'carousel',
                            height: 300,
                            items: [
                            {
                                html: 'html1',
                                style: 'background-color:#5E99CC'
                            },
                            {
                                html: 'html2',
                                style: 'background-color: #759E60'
                            },
                            {
                                html: 'html3',
                            }
                            ]
                        },//end carousel
                        {
                            xtype: 'label',
                            id: 'datalabel',
                            //tpl:  '{store.get("data")},{store.get("earn")}',
                            store: 'interestsdata',
                            //tpl: ['总投资:{data},盈利:{earn}'],
                            html: 'hello',
                            flex: 1,
                        }//end label
                    ]
                }
                ]//end items
            },
            {
                title: '融资',
                iconCls: 'locate',
                //xtype: 'makemoney'
            },
            {
                title: '理财',
                iconCls: 'action',
                //xtype: 'money'
            },
            {
                title: '账户',
                iconCls: 'user',
                //xtype: 'user'
            },
            {
                title: '更多',
                iconCls: 'more',
                //xtype: 'more'
            }
        ]
    }
});

2 个答案:

答案 0 :(得分:0)

尝试

Source: local data frame [9 x 8]
Groups: var

   var        term      estimate  std.error    statistic   p.value    conf.low conf.high
1 var1 (Intercept)  0.1298513867 0.17715588  0.732978145 0.4653394 -0.22175399 0.4814568
2 var1         BAF -0.0415096698 0.30068830 -0.138048836 0.8904880 -0.63829271 0.5552734
3 var1         LRR  0.0001270982 0.09550805  0.001330759 0.9989409 -0.18942994 0.1896841
4 var2 (Intercept)  0.1064316834 0.18173583  0.585639517 0.5594779 -0.25426363 0.4671270
5 var2         BAF  0.0144181386 0.31656921  0.045544981 0.9637666 -0.61388410 0.6427204
6 var2         LRR -0.0470190629 0.09340229 -0.503403723 0.6158217 -0.23239676 0.1383586
7 var3 (Intercept)  0.0616288934 0.17865709  0.344956329 0.7308741 -0.29295597 0.4162138
8 var3         BAF  0.1045320710 0.31246736  0.334537572 0.7386962 -0.51562914 0.7246933
9 var3         LRR  0.1118595808 0.07714709  1.449952134 0.1502976 -0.04125603 0.2649752

并选择这样

{
    xtype: 'label',
    itemId: 'datalabel',
    //tpl:  '{store.get("data")},{store.get("earn")}',
    store: 'interestsdata',
    //tpl: ['总投资:{data},盈利:{earn}'],
    html: 'hello',
    flex: 1,
}

答案 1 :(得分:0)

确保您已在app.js中添加了控制器文件。请尝试以下代码。

查看代码

xtype: 'label',
itemId: 'datalabel', // define item id here
//tpl:  '{store.get("data")},{store.get("earn")}',
store: 'interestsdata',
//tpl: ['总投资:{data},盈利:{earn}'],
html: 'hello',
flex: 1

控制器代码。

Ext.define('ylp2p.controller.viewdata',{
    extend: 'Ext.app.Controller',
    config: {
        control: {
            'main #datalabel'{
                show: 'viewlabelFn'
            }
        }
    },    
    viewlabelFn: function(){
        alert('painted');
    }
});