View Full Version : Populate combo list from the forms loaded data?
fgpaz13
21 Jan 2009, 1:53 AM
Hi Guys,
Is there a way that the combo box will get its data from the json data loaded for the form. Here is the scenario I have this ext form that i loaded the values dynamically and inside that form there are combo box that the list is specific to a certain account access. Is there a way that the combo box will get its data/populate the list from the ones loaded for the form? Bec. there are four combo box which means four different connection.:s
any help will be appreciated.
Animal
21 Jan 2009, 2:00 AM
It just works.
If you have some problem, you will have to post code.
fgpaz13
24 Jan 2009, 3:49 AM
What I'm planning to achieve is to load the combo's data using the same json data loaded on the form. My problem is the list doesn't show up on the combo list. Maybe i am missing something here.
Here's my code:
var clientStore = new Ext.data.SimpleStore({
fields: ['id', 'value'],
data:[
[12344,"Microsoft"],
[12345,"Apple Computers"]
]
});
Ext.onReady(function(){
Ext.QuickTips.init();
var simple = new Ext.form.FormPanel({
id: 'simpleForm',
title: 'Simple Form',
labelWidth: 75,
frame: true,
reader: new Ext.data.JsonReader({
totalProperty: "results",
root: "rows",
id: "id"
}, [{
name: 'trade_id'
}, {
name: 'client_id'
}, {
name: 'clients'
}]),
bodyStyle: 'padding:5px 5px 0',
width: 350,
items: [{
xtype: 'textfield',
fieldLabel: 'Trade ID',
name: 'trade_id'
}, {
xtype: 'combo',
fieldLabel: 'Client',
name: 'client_id',
hiddenName: 'client_id',
displayField: 'value',
valueField: 'id',
store: clientStore,
mode: 'local'
}],
listeners: {
actioncomplete: function(form, action){
if (action.type == 'load') {
// this should load combo new list from forms json data
//console.debug(action.result.data.clients);
clientStore.loadData(action.result.data.clients);
}
}
},
renderTo: Ext.getBody()
});
simple.load({ url: 'data.json', waitMsg: 'Loading..'})JSON Code:
{"results": 1,"rows": [{"trade_id":1023,"client_id":12345,"clients": [[12344,"Microsoft"],[12345,"Apple Computers"],[12346,"Thompson"]]}]}
Animal
25 Jan 2009, 1:43 AM
You shouldn't have name and hiddenName the same.
Don't specify a Reader.
Send back just
{success: true, data: { "trade_id":1023,"client_id":12345,"clients": [[12344,"Microsoft"],[12345,"Apple Computers"],[12346,"Thompson"]]}}
Obviously. result.data.blah requires that your response has data
Did you read this: http://extjs.com/deploy/dev/docs/?class=Ext.form.Action.Load ?
fgpaz13
26 Jan 2009, 6:56 PM
Ok. figure it, out my only problem was when the form has done loading the data the combo list data disappears. Lacking with one config which is triggerAction. btw, i removed the reader. thanks for your help!
{
xtype: 'combo',
fieldLabel: 'Client',
hiddenName: 'client_id',
triggerAction:'all',
allowBlank : true,
editable:false,
displayField: 'value',
valueField: 'id',
store: clientStore,
mode: 'local'
}
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.