2

你好!

我希望从视图中删除此处理程序“处理程序:onEventControler (???)”(它不属于那里)

对于网格视图设置 dockedItems 这个代码:

        this.dockedItems = [{
        xtype: 'toolbar',
        items: [{
            xtype: 'newstation'
        },{
            id: 'add-persone-btn',
            xtype: 'button',
            itemId: 'add',
            text: 'Add',
            iconCls: 'icon-add',  
            handler: onEventControler(???)
        }, '-', {
            itemId: 'delete',
            text: 'Delete',
            iconCls: 'icon-delete',
            disabled: true,
            handler: function(){
                var selection = grid.getView().getSelectionModel().getSelection()[0];
                if (selection) {
                    store.remove(selection);
                }
            }
        }]
    }]

我也尝试实现this.control,但我无法要求按钮 selectorQuery。

我如何正确尊重架构 mvc extJs4?

谢谢你。

4

2 回答 2

1

您应该能够在此视图的控制器中执行类似的操作。

init: function () {
  this.control({
    'toolbar #add': {
      click: this.onAddStation
    }        
  });
}

处理程序:

onAddStation: function(button, e, eOpts){
  //Handle
}

或者,您可以在按钮上使用“操作”配置。

action: 'addstation'

然后你可以有:

init: function () {
  this.control({
    'button[action=addstation]': {
      click: me.onAddStation
    }        
  });
}

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.button.Button

于 2012-02-19T18:04:30.827 回答
0

这是视图网格视图的方法“initComponent”:

initComponent: function () {
    this.plugins = [Ext.create('Ext.grid.plugin.RowEditing')];

    this.dockedItems = [{
        xtype: 'toolbar',
        items: [{
            xtype: 'button',
            itemId: 'add',
            text: 'Add',
            iconCls: 'icon-add',
            action: 'add-new-persone'
        }, '-', {
            itemId: 'delete',
            text: 'Delete',
            iconCls: 'icon-delete',
            action: 'delete-persone',
            disabled: true
        }, '-', {
            itemId: 'synch',
            text: 'Synchronization',
            iconCls: 'icon-synch',
            action: 'synch-persone'
        }]
    }];

    // paging bar on the bottom
    this.bbar = Ext.create('Ext.PagingToolbar', {
        store: this.store,
        displayInfo: true,
        displayMsg: 'Displaying topics {0} - {1} of {2}',
        emptyMsg: "No topics to display",
        items:[]
    });

    this._initColumns();
    this._initFilter();
    this.callParent(arguments);
},
于 2012-02-28T12:25:02.107 回答