PDA

View Full Version : Populating combo on form load



pajamabob
25 Dec 2009, 8:30 AM
I have created a dynamic form engine. All is working fine with the exception of populating combo controls with both hidden values and display values from a Json string.

The combo definition looks something like this:


{
'xtype':'combo',
'fieldLabel':'This Field Label',
'id':'fld_1DisplayValue',
'name': 'fld_1DisplayValue',
'hiddenName': 'fld_1',
'handler': '',
'submitValue':true,
'anchor':'100%',
'store':comboStore,
'mode':'remote',
'triggerAction': 'all',
'displayField':'DisplayValue',
'valueField':'RecordValue',
'loadingText':'Loading',
'pageSize':10,
'listeners':{ 'focus': function(thisField) { DoSetComboDataSource(thisField); }, 'blur': function(thisField) { thisField.collapse(); }}
}


The Json string (the important parts) look like this:

{ 'fld_1': '4', 'fld_1DisplayValue': 'This display value'}


When the form data is loaded all fields populate as expected, with the exception of the combos. Both the hidden value and display values are populated with “4”. I would expect that the display value would be “This display value”.

Any guidance would be much appreciated.

flanders
25 Dec 2009, 8:42 AM
You refer to a combostore, can you also post the configuration of that store?

pajamabob
25 Dec 2009, 9:04 AM
I can get you the store configuration, but the store is working just fine when making changes to the combo, all works just fine. The only problem is the initial load of data.




thisReaderConfig[0] = {name: 'DisplayValue'};
thisReaderConfig[1] = {name: 'RecordValue'};



var thisJsonReader = new Ext.data.JsonReader({
root: 'records',
totalProperty: 'totalCount',
idProperty: 'RecordValue',
fields: thisReaderConfig

});





comboStore = new Ext.data.Store({
autoLoad: false,
autoDestroy: true,
proxy: new Ext.data.ScriptTagProxy({
url: parent.top.EvolveServer + "/Json/comboData.asp"
}),
reader:thisJsonReader,
baseParams: {sourceName:'', List:'', FunctionalGroup:parent.top.app_UserFunctionalGroup, Language:parent.top.app_UserLanguage}
});

});

flanders
25 Dec 2009, 11:11 AM
I've been playing a while after your last post, but can't figure it out.

For a way the problem you could instead of trying to set both the hidden and visible value, set only the hidden value. When the combostore is completly loaded, you can execute combox.setValue(combobox.getValue()) and the combobox can automatically map the given hidden value to the correct display value.

I even wonder if it's possible to set both values by hand, since this opens the possibility for setting a non-matching pair.

pajamabob
25 Dec 2009, 9:43 PM
I will give that a try, thanks...

pajamabob
27 Dec 2009, 8:08 AM
OK, I tried this, but it did not solve the problem. It may be the way I am using the store. It is shared among all combos on the form. I ill see if I cn change this.

Do you have an example of declaring a store "in-line" with a combo definition?

pajamabob
27 Dec 2009, 9:10 AM
OK, after making myself nuts, I found that the injuries were self inflicted. I was trying to use a single data store for all combos on a page. This actually worked very well for everything but getting the initial display value.

I finally just declared in-line stores for each combo box and all is working just fine.

Thank you for your help in this matter.

Regards,
Bob