1
votes

I am trying to pass values from one view to another view, Below is the code what I have tried so far but no luck,

view1.js

var newWindow = Ext.create( 'newView', {"clickedRule" : clickedvalue} );
    signerWindow.show();

newView.js

Ext.define('newView', {
      extend : 'Ext.window.Window',
          id : 'newWindow',
 constructor : function (clickedRule){
                 Ext.applyIf(this, clickedRule);
                    this.callParent();
               },         
    requires : ['Ext.form.Panel'],
       title : 'Title Selection'+ this.clickedRule
}); 

I am getting undefined, your help is greatly appreciated.

Thanks in advance.

1

1 Answers

1
votes

Do it in Ext.create:

var newWindow = Ext.create( 'newView', {
    clickedRule : clickedvalue, 
    title       : 'Title Selection ' + clickedValue
});
newWindow.show();

and lose the title config on the class:

Ext.define('newView', {
      extend : 'Ext.window.Window',
          id : 'newWindow',
 constructor : function (clickedRule){
                 Ext.applyIf(this, clickedRule);
                    this.callParent();
               },         
    requires : ['Ext.form.Panel']
});

Edit from comment:

You will have to put it in the initComponent function in that case:

this refers to an instance of your window class so won't be available in the class definition (config statements) but you can access it after the class has been initialized using the initComponent function:

Ext.define('newView', {
      extend : 'Ext.window.Window',
          id : 'newWindow',
initComponent: function (){

                 var clickedRule = this.clickedRule; 

                 // title can also be defined here
                 this.title = 'Title Selection ' + clickedRule;

                 this.callParent();
               },         
    requires : ['Ext.form.Panel']
});

initComponent is the normal way of adding constructor logic to ExtJS components. See this in the docs.

Keep your original create statement:

var newWindow = Ext.create( 'newView', {clickedRule : clickedvalue} );

You can access the clickedRule property after the create statement:

console.log(newWindow.clickedRule);