【问题标题】:activate and paintied is not working in ext js激活和paintied在ext js中不起作用
【发布时间】:2020-06-18 11:44:58
【问题描述】:

分机中有一个网格列表页面。

查看:

Ext.define('App.view.client.ClientListView', {
    extend      : 'Ext.container.Container',
    xtype       : 'client-list',
    controller   : 'client',
    items:
    [
        {
            xtype   : 'panel',
            title   : 'Clients List',
            items   :
            [
                {
                    xtype       : 'grid',

                    columns: [
                        {
                            text        :'Mobile Number',
                            dataIndex   : 'mobile',
                          },
                        {
                            text        :'Email',
                            dataIndex   : 'email',
                          }
                     ],
                    store:Ext.create('dialgod.store.ClientStore'),
                    dockedItems:
                    [
                        {
                            xtype        : 'pagingtoolbar',
                            dock         : 'bottom',
                            displayInfo  : true
                        },
                        {
                            xtype     : 'toolbar',
                            height    : 50,
                            docked    : 'top',
                            items     :
                            [
                                {
                                    xtype    : 'button',
                                    text     : 'Add Client',
                                    name     : 'btn_add_client',
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]

});

控制器:

Ext.define('App.controller.ClientController', {
extend: 'Ext.app.ViewController',
alias: 'controller.client',
init: function() {
    this.control({
        'client-list':
        {
            activate    : this.loadClientsList,
            painted     : this.loadClientsList
        },
        'client-list button[name=btn_add_client]':{
            click   : this.AddClientForm
        },

    });
},

loadClientsList: function(listObj)
{
    console.log("loading client");
    var storeObj    = listObj.down("grid").getStore();
    storeObj.load();
},


AddClientForm : function(){
    console.log("client add form clicked");
    }

所有的点击功能在这个控制器中工作正常。 激活、绘制都不起作用。 加载网格页面时,我无法控制此激活功能。所以没有初始化加载这个网格。所以任何激活的解决方案,涂漆的操作系统不正确或其他任何使用负载的方法?任何人都可以建议。

【问题讨论】:

  • 你用的是extjs还是sencha-touch框架,什么版本?

标签: javascript html extjs sencha-touch


【解决方案1】:

在 ExtJs 经典工具包中: Ext.container.Container 的 'activate' 事件 “仅当此组件是使用 Ext.layout.container.Card 作为其布局的 Ext.container.Container 的子级或此组件是浮动组件时才会触发此事件。 ”。您没有在组件中使用卡片布局。 我在 Sencha Touch 中发现了“painted”事件,但同时 Ext.container.Container 不是 sencha touch 的一类。 无论如何,您可以使用 'render' 或 'show' (grid.show()/hide()) 事件来加载您的商店。 您的控制器将具有以下外观:

...
...
init: function() {
    this.control({
        'client-list':
        {
            render: this.loadClientsList,
            //show: this.loadClientsList fires in case of visual show/hide
        },
        'client-list button[name=btn_add_client]':{
            click   : this.AddClientForm
        },

    });
},
...
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-25
    • 2022-01-11
    • 1970-01-01
    • 2018-04-25
    • 2012-12-01
    • 2011-09-26
    • 1970-01-01
    相关资源
    最近更新 更多