Omar Faruq Omar Faruq - 3 months ago 10
Javascript Question

How can i declare global variable in the controller in extjs4.1?

I face some problem i can not declare global variable in extjs 4.1 controller if any one can help me how can i declare it.I donot know how i declare it
here is my code

Ext.define('Ext4Example.controller.poscontroller', {
extend: 'Ext.app.Controller',
//models: ['Vat','Rebate','Customer','Product','Invoice','Item','Order','Paymethod'],
stores: ['InvoiceIdFromSession','Vats','Rebates','Customers','Products','Invoices','Items','Paymethods'], //'Orders', ,'InvoiceIdFromSession','Products'
id : 'poscontroller',
views : ['stock.SaleWindow','stock.ItemForm2','stock.ItemsGrid','stock.CalculationForm'],
refs: [{
ref: 'itemForm',
selector: 'form'
}],
init: function() {
this.control({
'itemsgrid': {
removeitem: this.removeUser
},
'salewindow button[action=resetAll]': {
click: this.resertform
},
'salewindow button[action=saveOrder]' : {
click : this.onsaveOrder
},
'salewindow button[action=PDF]' : {
click : this. pdfreport
}
});
},

onsaveOrder : function(button){
// i want declare this variable to global variable

var itemform = Ext.getCmp('itemform2');
var calculation_Form =Ext.getCmp('calculation-form');
var ItemFrmdata = itemform.getForm().getValues();
var calcFrmdata = calculation_Form.getForm().getValues();


}

Answer

At last i do it .....

Ext.define('Ext4Example.controller.poscontroller', {
  extend: 'Ext.app.Controller',    
  //models: ['Vat','Rebate','Customer','Product','Invoice','Item','Order','Paymethod'],
  stores: ['InvoiceIdFromSession','Vats','Rebates','Customers','Products','Invoices','Items','Paymethods'], //'Orders', ,'InvoiceIdFromSession','Products'  
  id : 'poscontroller',
  views : ['stock.SaleWindow','stock.ItemForm2','stock.ItemsGrid','stock.CalculationForm'],
  refs: [{
    ref: 'itemForm',
    selector: 'form'
  }],
  init: function() {
    itemform  = Ext.getCmp('itemform2');
    calculation_Form = Ext.getCmp('calculation-form');
    ItemFrmdata = itemform.getForm().getValues(); 
    calcFrmdata = calculation_Form.getForm().getValues();
    this.control({
      'itemsgrid': {
        removeitem: this.removeUser
      },
      'salewindow button[action=resetAll]': {
        click: this.resertform
      },            
      'salewindow button[action=saveOrder]' : {
        click : this.onsaveOrder
      },
      'salewindow button[action=PDF]' : {
        click : this. pdfreport
      }
    });
  },

  onsaveOrder : function(button){           
  }
});