PDA

View Full Version : Form Panel, Combo Boxes and the API



jasondeegan
24 Apr 2008, 6:12 PM
Can I do a form panel and add a combo box as one of the items? (See code below)

Also, I am completely lost with the API -> Doing a search for FormPanel and then finding Items should contain a complex description for what is expected in the "items" attribute, yet all it says is "complex". Should an API not stand on its own without having to use forums to find code examples? PHP is an outstanding example of an API, this one is nearly unusable -> at least the way I'm familiar with it.

I have the same issue with data store. If I want to use the one example of a data store for a combo box (states), you're golden. But if I want to use a DAO (php page) that retrieves an XML file on the fly it's like you have to post a question to the board or find someone else with the exact same problem to get the proper syntax. I MUST be using the API wrong. Please advise.

Thanks!

Jason

How can I add a combo box (instead of a text or hidden field) based on an XML file retrieved from a DAO when it's rendered?

var login = new Ext.FormPanel({
labelWidth: 100, // label settings here cascade unless overridden
labelAlign: 'right',
baseCls: 'x-plain',
defaultType: 'textfield',
items: [{
fieldLabel: 'List Name',
name: 'listName',
id: 'listName',
allowBlank:false
},{
fieldLabel: 'action',
id: 'action',
inputType: 'hidden',
name: 'action',
value: 'addList',
allowBlank:false
},{
fieldLabel: 'hiddenOrg',
id: 'org',
inputType: 'hidden',
name: 'org',
value: Ext.get('org').getValue(),
allowBlank:false
}]
});

rudytheng
24 Apr 2008, 7:06 PM
{
xtype : 'combo', ??
fieldLabel: 'hiddenOrg',
id: 'org',
inputType: 'hidden',
name: 'org',
value: Ext.get('org').getValue(),
allowBlank:false
}

jasondeegan
24 Apr 2008, 8:19 PM
I would have expected that I would have had to set the source somewhere, no?

jasondeegan
24 Apr 2008, 9:32 PM
XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<tra>
<dta>one</dta>
</tra>
<tra>
<dta>two</dta>
</tra>
</root>

JS:

var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'test.xml'}),
reader: new Ext.data.XmlReader({ record: 'tra', id: 'tra' }, [ {name: 'adta', mapping: 'dta'} ] )
});
store.load();

var login = new Ext.FormPanel({
labelWidth: 100, // label settings here cascade unless overridden
labelAlign: 'right',
baseCls: 'x-plain',
defaultType: 'textfield',
items: [{
fieldLabel: 'List Name',
name: 'listName',
id: 'listName',
allowBlank:false
},{
fieldLabel: 'action',
id: 'action',
inputType: 'hidden',
name: 'action',
value: 'addList',
allowBlank:false
},{
xtype : 'combo',
id: 'qorg',
name: 'qorg',
store: store,
fieldLabel: '123',
valueField: 'adta',
displayField:'adta',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select',
selectOnFocus:true
},{
...