4

誰かが私にそれを宣言する方法を助けてくれるなら、私はextjs4.1コントローラーでグローバル変数を宣言できないといういくつかの問題に直面しています。私はここでそれを宣言する方法が私のコードです

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


}
4

3 に答える 3

7

idviewsまたはその他のプロパティを設定する方法と同じです。変数ではなくプロパティに名前が付けられていることだけを知っておく必要があります。

例:

//...
stores: ['InvoiceIdFromSession','Vats'], 
booleanVariable: true, 
stringVariable: 'demo',
floatVariable: .6,
objectVariable: { demo: 'test' }, 
id : 'poscontroller',
//...
于 2012-12-10T07:50:47.087 に答える
-1

ついにやる…。

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){           
  }
});
于 2013-01-28T11:55:43.797 に答える