PDA

View Full Version : How to get parent object metchod , variables



demon222
25 Mar 2010, 11:47 AM
Hi All
How to get parent valiable this.thing from window to form ???

HELP!!!!






Ext.form.tFAFieldType = Ext.extend( Ext.form.Hidden, {
initComponent : function() {
Ext.apply(this, {
name: 'field_type'
});
Ext.form.tFAFieldType.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldType', Ext.form.tFAFieldType);


Ext.form.tFAFieldName = Ext.extend( Ext.form.TextField, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldNameT'); ?>',
labelStyle: 'font-weight:bold',
name:'field_name',
anchor: '100%',
allowBlank: false,
blankText: '<?php echo $translate->_('requireFieldT'); ?>',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldNameT'); ?>') ]
});
Ext.form.tFAFieldName.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldName', Ext.form.tFAFieldName);


Ext.form.tFAFieldValue = Ext.extend( Ext.form.TextField, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldValueT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_value',
anchor: '100%',
allowBlank: false,
blankText: '<?php echo $translate->_('requireFieldT'); ?>',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldValueT'); ?>') ]
});
Ext.form.tFAFieldValue.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldValue', Ext.form.tFAFieldValue);

Ext.form.tFAFieldOption = Ext.extend( Ext.form.TextArea, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldOptionT'); ?>',
labelStyle: 'font-weight:bold',
height: '130px',
name: 'field_option',
anchor: '100%',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldOptionT'); ?>') ]
});
Ext.form.tFAFieldOption.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldOption', Ext.form.tFAFieldOption);


Ext.form.tFAFieldTip = Ext.extend( Ext.form.TextArea, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldTipT'); ?>',
labelStyle: 'font-weight:bold',
height: '130px',
name: 'field_tip',
anchor: '100%',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldTipT'); ?>') ]
});
Ext.form.tFAFieldTip.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldTip', Ext.form.tFAFieldTip);


Ext.form.tFAFieldWidth = Ext.extend( Ext.form.NumberField, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldWidthT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_width',
anchor: '100%',
allowBlank: false,
blankText: '<?php echo $translate->_('requireFieldT'); ?>',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldWidthT'); ?>') ]
});
Ext.form.tFAFieldWidth.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldWidth', Ext.form.tFAFieldWidth);


Ext.form.tFAFieldHeight = Ext.extend( Ext.form.NumberField, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldHeightT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_height',
anchor: '100%',
allowBlank: false,
blankText: '<?php echo $translate->_('requireFieldT'); ?>',
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldHeightT'); ?>') ]
});
Ext.form.tFAFieldHeight.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldHeight', Ext.form.tFAFieldHeight);


Ext.form.tFAFieldOrder = Ext.extend( Ext.ux.form.SpinnerField, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldOrderT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_order',
anchor: '100%',
allowBlank: false,
minValue: 0,
maxValue: 100,
blankText: '<?php echo $translate->_('requireFieldT'); ?>'
//plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldOrderT'); ?>') ]
});
Ext.form.tFAFieldOrder.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldOrder', Ext.form.tFAFieldOrder);


Ext.form.tFAFieldAligment = Ext.extend( Ext.form.ComboBox, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldAligmentT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_aligment',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data: ArrayFieldAlign
}),
mode: 'local',
hiddenName: 'field_aligment',
displayField: 'name',
valueField: 'value',
value: 't',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText: '<?php echo $translate->_('requireFieldT'); ?>',
selectOnFocus: true,
anchor: '100%',
allowBlank: false,
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldAligmentT'); ?>') ]
});
Ext.form.tFAFieldAligment.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldAligment', Ext.form.tFAFieldAligment);



Ext.form.tFAFieldRequire = Ext.extend( Ext.form.ComboBox, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldRequireT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_require',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data: ArrayYesNo
}),
mode: 'local',
hiddenName: 'field_require',
displayField: 'name',
valueField: 'value',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText: '<?php echo $translate->_('requireFieldT'); ?>',
selectOnFocus: true,
anchor: '100%',
allowBlank: false,
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldRequireT'); ?>') ]
});
Ext.form.tFAFieldRequire.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldRequire', Ext.form.tFAFieldRequire);


Ext.form.fAField = Ext.extend( Ext.form.FormPanel, {
constructor : function(config) {
config = config || {};
Ext.applyIf(config, {
trackResetOnLoad: true
});
Ext.form.fAField.superclass.constructor.call(this, config);
},

initComponent : function() {

Ext.apply (
this,
this.buildForm()
);

Ext.form.fAField.superclass.initComponent.call(this);
},

buildForm: function() {
return {
xtype: 'form',
labelWidth: 55,
border: true,
frame: true,
iconCls: 'iconEdit',
labelAlign: 'top',
monitorValid: true,
autoDestroy: true,
layout:'table',
layoutConfig: {
columns:2,
tableAttrs: {
style: {
border: 0
}
}
},
defaults: {width:300, border:false, frame:false, layout:'form', bodyStyle:'padding-left:5px; padding-right:5px'},
bodyStyle: 'padding-left:5px;padding-right:5px;',
items: this.buildFormItems()
};
},

buildFormItems: function() {

if (this.thing == 'a') {

var fields = [
{
items: [{xtype: 'tFAFieldName', value: this.thing}]
},
{
items: [{xtype: 'tFAFieldValue', value: this.thing}]
}
];
} else if (this.thing == 'h') {

var fields = [
{
items: [{xtype: 'tFAFieldValue', value: this.thing}]
}
];
} else {
var fields = [
{
items: [{xtype: 'tFAFieldValue', value: this.thing}]
}
];
};
return fields;

}
}); Ext.reg('fAField', Ext.form.fAField);

Ext.window.wAField = Ext.extend( Ext.ux.DemonWindow, {

constructor: function() {
this.thing = 'a';
Ext.window.wAField.superclass.constructor.apply(this, arguments);
},

initComponent : function() {

Ext.apply (
this,
this.buildWin()
);

Ext.window.wAField.superclass.initComponent.call(this);

this.on({
scope: this,
render: {
fn: this.loadFormAfterRender
}
});

this.on({
scope: this,
beforeshow: {
fn: this.loadFormBeforeShow
}
});

this.on({
scope: this,
afterrender: {
fn: this.loadFormAfterRender
}
});

this.on({
scope: this,
aftershow: {
fn: this.loadFormAfterShow
}
});


},

loadFormAfterShow: function() {

},

loadFormAfterRender: function() {

},

loadFormBeforeShow: function() {

},

loadFormAfterRender: function() {
this.add({xtype: 'fAField'});
},

buildWin : function() {

return {
iconCls: 'iconAdd',
layout: 'fit',
width: 635,
autoDestroy: true,
height: 435,
plain: false,
closable: false,
resizable: false,
draggable: true,
fieldStyle: 'padding:5px;',
buttonAlign: 'right',
title: '<?php echo $translate->_('FieldTitleAddT'); ?>',

fbar: [
{
cls: 'x-btn-text-icon',
iconCls: 'iconSave',
formBind: true,
text: '<?php echo $translate->_('saveT'); ?>',
tooltip:'<?php echo $translate->_('tipFieldSaveT'); ?>',
scope: this,
handler: function () {
fPAField.stopMonitoring();
bAFieldSave.disable();
fPAField.getForm().submit({
clientValidation: true,
url: '../backend/fields/insert/',
method: 'post',
params: {
test: 0
},
success: function (form, action) {
fPAField.getForm().reset();
wAField.hide();
storeFields.reload();
Ext.actionmsg.msg('<?php echo $translate->_('messageT'); ?>','<?php echo $translate->_('successFieldSaveT'); ?>');
bAFieldSave.enable();
fPAField.startMonitoring();
doSpotlight.hide();
},
failure: function (form, action) {
Ext.Msg.show({title:'<?php echo $translate->_('messageT'); ?>',msg:'<?php echo $translate->_('failureFieldSaveT'); ?>',icon: Ext.MessageBox.INFO,buttons: Ext.Msg.OK});
bAFieldSave.enable();
fPAField.startMonitoring();
}
});
}
},
{
xtype: 'button',
cls: 'x-btn-text-icon',
iconCls: 'iconClose',
text: '<?php echo $translate->_('cancelT'); ?>',
tooltip:'<?php echo $translate->_('tipFieldCancelT'); ?>',
scope: this,
handler: this.onClose
}
]
}
},



onClose : function() {
this.close();
},

onContent: function (type) {
this.setValue(type);
this.show();
},

getValue: function () {
return this.thing;
},

setValue: function (val) {
this.thing = val;
}


}); Ext.reg('wAField', Ext.window.wAField);


Ext.form.tFAFieldPreType = Ext.extend( Ext.form.ComboBox, {
initComponent : function() {
Ext.apply(this, {
fieldLabel: '<?php echo $translate->_('rowFieldTypeT'); ?>',
labelStyle: 'font-weight:bold',
name: 'field_pretype',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data: ArrayFieldType
}),
mode: 'local',
hiddenName: 'field_pretype',
displayField: 'name',
valueField: 'value',
value: 'a',
selectOnFocus: true,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText: '<?php echo $translate->_('requireFieldT'); ?>',
selectOnFocus: true,
anchor: '100%',
allowBlank: false,
plugins: [ new Ext.ux.FieldHelp('<?php echo $translate->_('helpFieldTypeT'); ?>') ]
});
Ext.form.tFAFieldPreType.superclass.initComponent.call(this);
}
}); Ext.reg('tFAFieldPreType', Ext.form.tFAFieldPreType);


Ext.window.winPreField = Ext.extend( Ext.ux.DemonWindow, {
initComponent : function() {
Ext.apply(this, {
iconCls: 'iconAdd',
layout: 'fit',
width: 335,
height: 125,
plain: false,
closable: false,
resizable: false,
draggable: true,
fieldStyle: 'padding:5px;',
buttonAlign: 'right',
title: '<?php echo $translate->_('FieldTitlePreT'); ?>',
items: [
{
xtype: 'form',
labelWidth: 55,
border: true,
frame: true,
iconCls: 'iconEdit',
labelAlign: 'top',
monitorValid: true,
layout:'table',
layoutConfig: {
columns:1,
tableAttrs: {
style: {
border: 0
}
}
},
defaults: {width:300, border:false, frame:false, layout:'form', bodyStyle:'padding-left:5px; padding-right:5px'},
bodyStyle: 'padding-left:5px;padding-right:5px;',
items:[
{
items: [new Ext.form.tFAFieldPreType()]
}
]
}
],
fbar: [
{
xtype: 'button',
cls: 'x-btn-text-icon',
iconCls: 'iconNext',
formBind: true,
text: '<?php echo $translate->_('nextT'); ?>',
tooltip:'<?php echo $translate->_('tipFieldNextT'); ?>',
scope: this,
handler: this.onNext
},
{
xtype: 'button',
cls: 'x-btn-text-icon',
iconCls: 'iconClose',
text: '<?php echo $translate->_('cancelT'); ?>',
tooltip:'<?php echo $translate->_('tipFieldCancelT'); ?>',
scope:this,
handler: this.onClose
}

]
});
Ext.window.winPreField.superclass.initComponent.call(this);
},

onClose : function() {
this.close();
},

onNext: function () {
var win = new Ext.window.wAField();
win.setValue(Ext.getDom('field_pretype').value);
win.show();
this.close();
},

onContent: function () {
this.show();
}

}); Ext.reg('winPreField', Ext.window.winPreField);