PDA

View Full Version : help with loading metadata and sorting



FritFrut
21 Jun 2007, 7:16 AM
Hello
I'm trying to use AutoGrid, as described in a few articles here. I'm also using slightly modified JsonReader and a proxy class similar to DWRProxy. My Store is set to remoteSort.
My first call to load data looks like this:

dataSource.load({params:{start:0, limit:pageSize}, meta: true});
I have configured JsonReader like this:

Ext.data.JsonReader({root: 'result.data',
totalProperty: 'result.total',
metaProperty: 'result.metaData',
id: 'id'})
where 'metaProperty' is the name of the property which holds the metadata.
My JSON RPC Proxy class is similar to DWRProxy. Here's the load method:

this.load = function(params, reader, callback, scope, arg)
{
var loadMeta = arg.meta || false ;
_jsonRpcProxy[listMethod] (params.start, params.limit, params.sort, params.dir, loadMeta,
this.loadResponse.createDelegate(this, [reader, callback, scope, arg], true )
).call(Tom.JsonRpcProxy.ext_channel1);
}
Everything works fine, but there's a little problem: sorting on columns doesn't work if I don't change a current page of data. I believe that the problem is in the sort method in Store. If remote sort is used, it just calls load with the lastOptions parameter, which again loads the metadata:

this.load(this.lastOptions);
(my metadata has default sortinfo value).
After I change page of data, meta property is removed from the lastOptions and everything works as expected.
So, my question is, am I doing something wrong, or is this a bug? What is the best way to change he lastOptions? This is marked as private, so I'd rather not poke too much if not necessary.

methodz
8 Nov 2007, 8:32 AM
Have you had any luck with this issue?

methodz
8 Nov 2007, 3:23 PM
I solved this problem by overriding the Store's sort method and dropping the meta property from lastOptions.

[PHP]Ext.override(Ext.data.Store, {
load : function(options){
options = options || {};
if(this.fireEvent("beforeload", this, options) !== false){
this.storeOptions(options);
var p = Ext.apply(options.params || {}, this.baseParams); //

tof
24 Jan 2008, 8:01 AM
I encountered the same problem.
My workaround has been server side, I send metaDatas only when no "sort" field has been sent.
This is to be filled as a bug :(

tof
24 Jan 2008, 8:10 AM
This is actually specified in the documentation of jsonReader that only the first resultSet should have metaDatas (but if they change, of course) :


The first data packet from the server would configure the reader by containing a metaData property as well as the data:...

So, I won't file any bug report :>

genius551v
6 Mar 2008, 6:04 AM
methodz, great solution, this wors fine for me, tnks a millon...\:D/