PDA

View Full Version : [NOREPRO] remoteSort doesn't work with BufferedStore



tbraytff
25 Apr 2014, 9:15 AM
I've got a grid hooked up to the store below. If the store extends Ext.data.Store, remoteSort works as expected, but when I extend Ext.data.BufferedStore, the sorters don't get updated or applied (no asc/desc arrow on the columns either).


Ext.define('IFN.store.Accounts',{
extend: 'Ext.data.BufferedStore',
//extend: 'Ext.data.Store',


requires: [
'IFN.model.Account'
],


storeId:'all-accounts',


model: 'IFN.model.Account',


proxy: {
type: 'rest',
url: IFN.config.Config.getBaseUrl() + '/accounts',
reader: {
rootProperty:'data',
totalProperty: 'totalCount'
},
startParam:"offset",
limitParam:"max",
sortParam:"sort",
simpleSortMode:true,
directionParam:"order"
},


pageSize: 200,
buffered: true,
remoteSort: true,
remoteFilter:true,
autoLoad:false


})

mitchellsimoens
25 Apr 2014, 9:25 AM
If I have this:


Ext.define('Fiddle.store.Foo', {
extend : 'Ext.data.BufferedStore',

autoLoad : true,
remoteSort : true,

fields : [
'foo'
],

proxy : {
type : 'ajax',
url : '/data/json.json'
},

sorters : [
{
property : 'foo'
}
]
});

The url has the sort info:


http://test/data/json.json?_dc=1398446655983&page=1&limit=25&sort=%5B%7B%22property%22%3A%22foo%22%2C%22direction%22%3A%22ASC%22%7D%5D

which has this query string param:


sort:[{"property":"foo","direction":"ASC"}]

tbraytff
25 Apr 2014, 9:30 AM
It looks like the problem is with the grid interacting with the BufferedStore. I bet that if you hook that store up to a grid and click the column header, the sorters won't update.

tolgaerdogus
17 May 2014, 7:30 AM
Easy to see - look at your own sample:
http://dev.sencha.com/ext/5.0.0/examples/grid/infinite-scroll.html

Click on Topic column and sort doesn't happen even though the column is defined as:


{ tdCls: 'x-grid-cell-topic', text: "Topic", dataIndex: 'title', flex: 1, renderer: renderTopic, sortable: true, wrap: true }

n00b
15 Jun 2014, 12:34 AM
+1, doesn't work, no sort property/order is sent with ajax unless you explicitly set :

sorters: [{
property: 'colname',

direction: 'DESC'
}],

in the Ext.data.BufferedStore but still, with this piece of code, only the specified column is sorted, the others are ignored even if the sort arrow appears on column headers.


Visible in the example here :http://dev.sencha.com/extjs/5.0.0/examples/grid/buffered-store.html

intro
16 Jun 2014, 5:10 AM
This code is working for me : Ext.direct and BufferedStore

Ext.define('Ext.overrides.data.BufferedStore', {
override: 'Ext.data.BufferedStore',


sort: function(clm, dir, mode){
this.getSorters().addSort(clm, dir, mode);
this.callParent(arguments);
}
});

ipbs
26 Feb 2015, 4:41 AM
Thanks intro ! this worked for me too !
Here is my complete Override (to fix the bug on sort after selection also) :



Ext.data.BufferedStore.override({

// FIXES BUG ON SORT AFTER ROW SELECTION
// http://stackoverflow.com/questions/19953421/extjs-4-2-error-getbyid-called-for-id-that-is-not-present-in-local-cache-when
// http://www.sencha.com/forum/showthread.php?258397-4.2.0-RC-Selecting-a-grid-s-row-with-a-buffered-store-causes-a-JavaScript-error&p=979038&viewfull=1#post979038
getById: function(id) {
console.log("getById override: "+ id);
var result = (this.snapshot || this.data).findBy(function(record) {
return record.getId() === id;
});
if (this.buffered && !result) {
return [];
}
return result;
},

// FIXES SORTING BUG IN BUFFERED STORES IN EXTJS 5.0
// http://www.sencha.com/forum/showthread.php?284772-remoteSort-doesn-t-work-with-BufferedStore&p=1049663&viewfull=1#post1049663
sort: function(clm, dir, mode){
this.getSorters().addSort(clm, dir, mode);
this.callParent(arguments);
}
});

VirtualGreg
7 Oct 2015, 4:47 PM
What is the status of this bug? I tried the provided override fix and it did not work for me.