Extjs change panel title to event

I have a grid panel like this

Ext.define('sCon.view.SalesGrid',{
        extend: 'Ext.grid.GridPanel',
        title: 'Sales Data',

        //other params   

        initComponent: function(){
            this.callParent(arguments);
        }
    });

In the click event, I want to change the title of this panel. My code inside the controller is as follows.

Ext.define('sCon.controller.SalesGridController', {
        extend: 'Ext.app.Controller',
        views: ['SalesGrid'],

        // other handlers

        changeTitle: function(newTitle){
            this.getView('SalesGrid').setTitle('title_changed');
        }

It is currently said that it does not have the setTitle () function. But the docs say the grid has a setTitle () function. I also tried changing the title using the variable 'title', for example

 changeTitle: function(newTitle){
            this.getView('SalesGrid').title = 'title_changed';

Does not work. Please, help.

+5
source share
2 answers

UPD: Here are some refsdocuments from Sencha for ExtJS 4.1.

Use the property of refsyour controller to get links to any components.

In your example:

Ext.define('sCon.view.SalesGrid',{
  extend: 'Ext.grid.GridPanel',
  title: 'Sales Data',

  alias: 'widget.salesgrid',

  //other params   

  initComponent: function(){
    this.callParent(arguments);
  }
});

In the controller add:

refs: [
  { ref: 'salesGrid', selector: 'salesgrid', },
]

SalesGrid , , this.getSalesGrid();.

:

changeTitle: function(newTitle){
  this.getSalesGrid().setTitle('title_changed');
}
+9

webbandit , .

, !

this.getView('SalesGrid').create().setTitle('title_changed');

. API

+3

All Articles