PDA

View Full Version : I have the problem with the ComboBox



lu7jm
Jun 08, 2020, 3:49 AM
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(resu lt);
}

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.getVal ue(); " success="loadBulletinNumbers">
</change>
</directEvents>
</ext-combobox>

fabricio.murta
Jun 09, 2020, 11:19 PM
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!

lu7jm
Jun 09, 2020, 11:46 PM
Now it works :) Thanks