frosty
frosty

Reputation: 5370

how to call a view from a controller in extjs mvc 4

I have RowEdit in my view. I would like to able to call the controller so i can save the model.

My View

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
    clicksToMoveEditor: 1,
    autoCancel: false,
    listeners: {
        afteredit: function () {
          // i want to call the controller from here
        }
    }
});

Ext.define('Pandora.view.MaterialsList', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.materialslist',
    store: 'Materials',
    title: 'Materials',
    plugins: [rowEditing]
}

I appreciate i may be going about this the wrong way and should be trying to catch this event in my controller but I have been unable to catch the event in my controller.

Upvotes: 0

Views: 1107

Answers (1)

David Kanarek
David Kanarek

Reputation: 12613

According to the docs, the event you want is edit not afteredit. Try listening to that in your controller.

In case you still want to be able to do what you've asked:

In one of your controllers, in the init code, you will need to assign the application to a global variable. APP = this.application

Then, anywhere in your application, you can say APP.getController('myController').myMethod()

Upvotes: 3

Related Questions