Results 1 to 7 of 7

Thread: Populating combo on form load

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2007
    Location
    Manchester NH
    Posts
    42

    Default Populating combo on form load

    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:

    Code:
    {
    '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:
    Code:
    { '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.

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327

    Default

    You refer to a combostore, can you also post the configuration of that store?

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2007
    Location
    Manchester NH
    Posts
    42

    Default

    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.

    Code:
    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} 
        });
    
    });

  4. #4
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327

    Default

    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.

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2007
    Location
    Manchester NH
    Posts
    42

    Default

    I will give that a try, thanks...

  6. #6
    Sencha Premium Member
    Join Date
    Oct 2007
    Location
    Manchester NH
    Posts
    42

    Default

    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?

  7. #7
    Sencha Premium Member
    Join Date
    Oct 2007
    Location
    Manchester NH
    Posts
    42

    Default [Solved]

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •