PDA

View Full Version : Placement of variable for use in combobox url



Tumac
7 Jul 2010, 10:24 AM
I have a button associated with my grid, that when i press for "NEW LINE" it opens up a new window with an input form (below).

I am passing the keyfield to the pop-up form as a hidden field.

On the form, I have a combobox that I would like to pass the keyfield to the store so the store only returns records associated with that keyfield in the dropdown.

I have tried placing this var can=Ext.getCmp('container').getValue(); in many places and get the consistent result

Ext.getCmp('container').getValue() is undefined

I assume this is because it is trying to retrieve this value before the pop-form is rendered. Should it be a listener on the combo that onClick gets the value?




Ext.ns("STScls.form");

STScls.form.TallyDetailForm = Ext.extend(STScls.form.FormPanelBaseCls, {
border : true,
autoScroll : true,
bodyStyle : 'background-color: #E8EDEA; padding: 10px',
layout : 'form',
defaultType : 'textfield',

initComponent : function(container) {
Ext.applyIf(this, {
items : [
this.buildFormFields()
]
});

STScls.form.TallyDetailForm.superclass.initComponent.call(this);

this.addEvents({
savedetail : true
});

if (this.record) {
this.on({
scope : this,
render : {
single : true,
fn : this.loadFormAfterRender
}
});
}
},

buildFormFields : function(container) {
var tallyContainer = this.buildTallyContainer(can);

return [
{
xtype : 'hidden'
,name : 'tallyID'
},{
xtype : 'hidden'
,name : 'container'
,id : 'container' <-- KEYFIELD If I make unhidden, my value is there
,itemId: 'container'
},
tallyContainer
];
var can=Ext.getCmp('container').getValue(); <--UNDEFINED
//var can=Ext.get('container').getValue();
}

,buildTallyContainer : function(can) {
console.log(can);
return {
xtype : 'container'
,layout : 'column'
,defaultType : 'container'
,anchor : '-10'
,defaults : {
layout : 'form'
,labelAlign : 'top'
,anchor : '-10'
,layoutConfig :{
labelStyle : 'font-weight:bold;text-align:center;border:1px solid navy;'
,labelSeparator : ''
}
}
,items : [
{
width: 110
,items: {
xtype: 'combo'
,fieldLabel: 'PO #'
,name: 'comboPO'
,displayField:'poID'
,allowBlank: false
,valuefield: 'poID'
,hiddenName: 'poID'
,triggerAction:'all'
,width: 109
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=canPOList&can='+can <---- THIS IS THE VARIABLE
,autoLoad: false
,root: 'data'
,fields: ['container','poID','crates','transitStatus']
}
}
},{

7 Jul 2010, 10:30 AM
1) Do not use Ext.getCmp inside of your classes.
2) Why would you want to get the value before you've set it?!!?
3) The instance of Ext.form.HiddenField has not been created yet.
4) See below image:
http://tdg-i.com/img/screencasts/2010-07-07_1429.png

Animal
7 Jul 2010, 10:42 AM
@OP See the ref config

7 Jul 2010, 10:49 AM
ref won't help him because of the order in which he's trying to use it.

http://tdg-i.com/img/screencasts/2010-07-07_1448.png

Tumac
7 Jul 2010, 10:54 AM
So my presumption is correct, you validated that. So it goes to my question, where/how should i pick up the value once the form is rendered to pass it to my combo? This is based on your code from the book (yes I purchased).

It is like I associate employee with dept in an earlier process. In the new cardpanel, I click on the department list and get dept info loaded into the form. the detail grid on the form contains data about employees that are already part of the department. So I click NEW and have it pass the dept ID into the hidden container, the EmployeeEditorWindow form has a combobox with THAT dept's employees.

Does that make sense?

In my case:

I populate the form from a master grid on the West. I then click "NEW" on the detail grid (which opens a new form for data input) and pass the container(keyfield) to the hidden. On an earlier process I have already associated poID's with containers.

Now I want to add Item detail to the DB, so when I click NEW, I want only those PO's that are associated with the "container" to be listed in the combobox.

Tumac
7 Jul 2010, 11:00 AM
I may have some bad references still hanging around because I have tried to pass it several ways. I use this function to pass the keyfield data into the EditorForm (from the "Manager")

This populates the hidden "container" field on the form.



,onFormNewDetail : function(transitForm) {
var container = transitForm.getValues().container;
new STS.TallyEditorWindow({
container: container
,listeners : {
detailsaved : {
single : true,
scope : this,
fn : this.detailSaveSuccess
}
}
}).show();
}

Tumac
7 Jul 2010, 3:44 PM
From the class that loads the form, I pass the container, then simply use the variable....was making it too complicated before.....

first call to build form:


buildDetailForm : function() {

return {
xtype : 'tallydetailform'
,border : false
,itemId : 'tallydetailForm'
,record : this.record
,container: this.container
,tbar : null
};
},


Then in form



,items: {
xtype: 'combo'
,fieldLabel: 'PO #'
,name: 'comboPO'
,displayField:'poID'
,allowBlank: false
,valuefield: 'poID'
,hiddenName: 'poID'
,triggerAction:'all'
,width: 109
,store: {
xtype: 'jsonstore'
,url: '?c=lookup&m=canPOList&can='+this.container
,autoLoad: false
,fields: ['poID']
}
}