4
votes

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();


}
3

3 Answers

7
votes

Just like how you are setting the id, views or any other property. You only need to know that they named properties and not variables.

example:

//...
stores: ['InvoiceIdFromSession','Vats'], 
booleanVariable: true, 
stringVariable: 'demo',
floatVariable: .6,
objectVariable: { demo: 'test' }, 
id : 'poscontroller',
//...
0
votes

Try this:

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'
}],

/*These are Global variables for this controller,
Now you can get and set these variable according to your need*/
config:{
    itemform  : Ext.getCmp('itemform2'),
    calculation_Form : Ext.getCmp('calculation-form'),
    ItemFrmdata : this.getItemform().getForm().getValues(),  // for get declared Variable
    calcFrmdata : this.getCalculation_Form().getForm().getValues()  // for get declared Variable
},
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){

}
});
-1
votes

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){           
  }
});