-
25 Feb 2013 2:48 PM #1
Combo with store triggers store load, without autoLoad
Combo with store triggers store load, without autoLoad
When a store is assigned to a Combo, the store is loaded, even though the store should not autoLoad.
A filter is also applied, it includes the data-index av property, but no value.
When the same store is assigned to more than one combo the store is loaded several times, each store ads a filter.
Know issue?
I've tested with several versions, latest is with 4.2.0.540Sven Tore Iversen
-
27 Feb 2013 9:10 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
This code:
Using last night's nightly (also tested 4.2.0.489 = 4.2.0 RC1) it doesn't load the store until I click on the trigger or type in the box.Code:var store = new Ext.data.Store({ fields : ['text', 'value'], proxy : { type : 'ajax', url : 'data/json.json' } }); new Ext.form.Panel({ renderTo : document.body, items : [ { xtype : 'combobox', fieldLabel : 'Test', store : store, displayField : 'text', valueField : 'value' } ] });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Mar 2013 3:33 AM #3
After some more testing I've found that you have to add set remoteFilter:true so see the problem.
Still there in 625Sven Tore Iversen
-
10 Mar 2013 11:28 PM #4
Is this marked as a bug?
Sven Tore Iversen
-
11 Mar 2013 8:08 AM #5
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
11 Mar 2013 8:44 AM #6
OK, but ignore the multiple combos, then.
In 4.1 I could use the same store on multiple combos just fine.
The error is there with just one combo.
The problem, really, is that when the combo adds the filter to the store the store is loaded, even though the store is autoLoad:false if the store has remoteFilter:true.
Why does the combo add a filter to the store? The filter data only contains a property, not a value. The value is not sent to the server as a part of the filter, it is sent as a query parameter.
This code should NOT trigger a request:
The above code trigger a request to:Code:<script type="text/javascript"> Ext.onReady(function(){ Ext.define('User', { extend: 'Ext.data.Model', fields: [ {name: 'login', type: 'string'}, {name: 'name', type: 'string'} ] }); var store = new Ext.data.Store({ model:'User', proxy: { type: 'rest', url: 'http://www.example.com/rest/users/', }, remoteFilter: true, autoLoad:false }); var combo = new Ext.form.ComboBox({ renderTo:'combo', store: store, displayField:'name', valueField:'login' }); }); </script> <div id="combo"></div>
When writing "test" in the combo it triggers:Code:http://www.example.com/rest/users/?_dc=1363019458867&page=1&start=0&limit=25&filter=%5B%7B%22property%22%3A%22name%22%7D%5D _dc:1363019458867 page:1 start:0 limit:25 filter:[{"property":"name"}]
The later is "ok" although i would prefer if "test" was a value property in the filter to allow it to use the same filtering logic as all other store filters.Code:_dc:1363019723543 query:test page:1 start:0 limit:25 filter:[{"property":"name"}]
Is this really the intended behavior?
It triggers to many problematic request for the backend. The server does not currently accept "filter" with only property and no "value". Also sending "all data" for every combo using the same data on opening the application is simply to slow. In my application the user will always search, and the store always gets additional filters before they are loaded.Sven Tore Iversen
-
11 Mar 2013 11:39 AM #7
Yes, I see.
It adds the filter just for future use. It's disabled so it should not cause any immediate effect.
I will add a ticket.
-
11 Mar 2013 12:46 PM #8
This will be fixed in 4.2.1, but as a workaround, try this override:
Code:Ext.override(Ext.data.Store, { filter: function(filters, value) { if (Ext.isString(filters)) { filters = { property: filters, value: value }; } var me = this, decoded = me.decodeFilters(filters), i, doLocalSort = me.sorters.length && me.sortOnFilter && !me.remoteSort, length = decoded.length, allDisabled = true; // Merge new filters into current filter set. for (i = 0; i < length; i++) { me.filters.replace(decoded[i]); } // Cheack that we have some enabled filters before attempting to filter for (i = 0, length = me.filters.items.length; i < length; i++) { if (!me.filters.items[i].disabled) { allDisabled = false; break; } } if (!allDisabled) { if (me.remoteFilter) { // So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count delete me.totalCount; // For a buffered Store, we have to clear the prefetch cache because the dataset will change upon filtering. // Then we must prefetch the new page 1, and when that arrives, reload the visible part of the Store // via the guaranteedrange event if (me.buffered) { me.data.clear(); me.loadPage(1); } else { // Reset to the first page, the filter is likely to produce a smaller data set me.currentPage = 1; //the load function will pick up the new filters and request the filtered data from the proxy me.load(); } } else { /** * @property {Ext.util.MixedCollection} snapshot * A pristine (unfiltered) collection of the records in this store. This is used to reinstate * records when a filter is removed or changed */ if (me.filters.getCount()) { me.snapshot = me.snapshot || me.data.clone(); // Filter the unfiltered dataset using the filter set me.data = me.snapshot.filter(me.filters.items); // Groups will change when filters change me.constructGroups(); if (doLocalSort) { me.sort(); } else { // fire datachanged event if it hasn't already been fired by doSort me.fireEvent('datachanged', me); me.fireEvent('refresh', me); } } } } me.fireEvent('filterchange', me, me.filters.items); } });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
13 Mar 2013 11:49 PM #9
Thanks.. Initial testing of the override seems to do the trick - Also working fine (afaik) with using the same store on multiple combos (In my case they should always display the same data, even if it is filtered etc)
Sven Tore Iversen
-
14 Mar 2013 11:35 AM #10
I had the same issue described with the store loading on my combo's with remoteFilter:true. I applied the patch and that issue was resolved. However...
I have grids with the following settings on their store:
remoteSort:true,
remoteGroup:true,
remoteFilter:true,
- In ExtJS 4.1.1 I would manually load my grids and autoLoad wasn't set or was set to false
- In ExtJS 4.2.0 my grid now auto loads (causing a double initial load in my case).
If I set all three remote options to false (and only then), then the store does not auto load as I had come to expect in ExtJS 4.1.1
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-9074
in
4.2.1.


Reply With Quote