I have the problem with the ComboBox

  1. #1

    I have the problem with the ComboBox

    I have 2 ComboBoxes, in one of them when selecting an element fires an event and returns a list of elements. Selecting an item the first time doesn't load the data into the second ComboBox, but if I re-select another item the second time if it loads, why does that happen? is there any way to force load?

    JavaScript Code:

    var loadBulletinYears = function (ev, result) {
        App.ComboBox_BulletinYears.getStore().setData(result);
    }
    Sample: file.cshtml

    <ext-combobox id="ComboBox_BulletinCountries" editable="false" displayField="Name" valueField="Code" fieldLabel="Pais" flex="1" emptyText="">
        <store>
            <ext-store data="Model.BulletinCountries" >
                <fields>
                    <ext-numberDataField name="Id" />
                    <ext-stringDataField name="Code" />
                    <ext-stringDataField name="Name" />
                </fields>
            </ext-store>
        </store>
        <directEvents>
            <change url="GetBulletinYears" before="extraParams.country = App.ComboBox_BulletinCountries.getValue();" success="loadBulletinYears">
            </change>
        </directEvents>
    </ext-combobox>
    
    
    <ext-combobox id="ComboBox_BulletinYears" editable="false"  displayField="Year" valueField="Year" fieldLabel="Publicación Año" flex="1" emptyText="">
        <store>
            <ext-store autoLoad="true">
                <fields>
                    <ext-stringDataField name="Year" />
                </fields>
                <sorters>
                    <ext-sorter property="Year" direction="DESC" />
                </sorters>
            </ext-store>
        </store>
        <directEvents>
            <change url="GetBulletinNumbers" before="extraParams.country = App.ComboBox_BulletinCountries.getValue(); extraParams.year=App.ComboBox_BulletinYears.getValue(); " success="loadBulletinNumbers">
            </change>
        </directEvents>
    </ext-combobox>
    Last edited by geoffrey.mcgill; Jun 08, 2020 at 4:22 AM.
  2. #2
    Hello @lu7jm, and welcome to Ext.NET Forums!

    You are just setting the data to the store but allowing the combo box to try to reload the store with remote data (server or whatever else source) the first time the store is loaded.

    You should either set up the store to load data from the server (with a reader) or just force the combo box's query mode to "local".

    In other words, just add queryMode="local" to your ext-combobox definition and it won't "unload" all data the first time you expand the combo box.

    Notice no matter how many times you change the the selected value in the first combo, the second will always show empty the first time you expand it due to this setting. It would also clear if you had it editable and entered queries to filter the dropdown in the default setup.

    That's because you are just giving data to the store, you are not telling it how it should gather data in case its load() method is called.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3

    Now it works :) Thanks

    Now it works :) Thanks

Similar Threads

  1. [CLOSED] Problem with combobox when select a data from another combobox
    By opendat2000 in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 25, 2015, 6:24 PM
  2. Combobox problem....!!!!!!!!!!!!!!
    By Juen in forum 2.x Help
    Replies: 1
    Last Post: Oct 06, 2012, 8:51 PM
  3. Problem about combobox
    By antenonline in forum 1.x Help
    Replies: 2
    Last Post: Dec 18, 2009, 10:10 AM
  4. Replies: 5
    Last Post: Jun 10, 2009, 5:13 AM
  5. ComboBox problem
    By Zarzand in forum 1.x Help
    Replies: 5
    Last Post: Oct 24, 2008, 1:37 PM

Posting Permissions