[英]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 我面临一些问题,我无法在extjs 4.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();
}
Just like how you are setting the id
, views
or any other property. 就像你设置id
, views
或任何其他属性一样。 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',
//...
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){
}
});
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){
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.