1. #1
    Ext User
    Join Date
    Jun 2008
    Posts
    42
    Vote Rating
    0
    vinnybozz is on a distinguished road

      0  

    Default [SOLVED] Help with DirectStore

    [SOLVED] Help with DirectStore


    Hi, I am trying to convert an existing Store using an HttpProxy and JsonReader to a DirectStore ...

    I just can't seem to make it work, here's a sample of my json store:

    Code:
    var store = new Ext.data.Store({
    	proxy: new Ext.data.HttpProxy({
    		method: 'POST',
    		url: 'ajax/get-users.php',
    		timeout: 120000
    	}),
    	reader: new Ext.data.JsonReader({
    			root: 'users',
    			totalProperty: 'totalCount'
    		},
    		[
    			{name: 'firstname', mapping: 'firstname'},
    			{name: 'lastname', mapping: 'lastname'},
    			{name: 'id', mapping: 'id'}
    		]
    	)
    })
    with server response:
    Code:
    {"totalCount":100,"users":[{"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname"
    :"Tran","id":"9954769"}]}

    I am replacing it with:

    Code:
    var store = new Ext.data.DirectStore({
    	directFn: TestAction.getUsers, 
    	paramsAsHash: true,
    	root: 'users',
    	totalProperty: 'totalCount',
    	idProperty: 'id',
    	fields: [
    				{name: 'firstname', mapping: 'firstname'},
    				{name: 'lastname', mapping: 'lastname'},
    				{name: 'id', mapping: 'id'}
    			]
    });
    which returns:
    Code:
    {"type":"rpc","tid":2,"action":"TestAction","method":"getUsers","result":{"totalCount":100,"users":[
    {"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname":"Tran","id":"9954769"
    }]}}
    It seems like the error occurs in the Reader, not being able to understand the data.

    If anyone has any ideas it would be greatly appreciated.

    Thx
    Dan

  2. #2
    Ext User
    Join Date
    Jun 2008
    Posts
    42
    Vote Rating
    0
    vinnybozz is on a distinguished road

      0  

    Default


    ok that was simple:

    PHP Code:
    paramsAsHashfalse

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    I had the same issue, setting paramsAsHash to false solved it. But I still don't understand exactly what it does. It's not very clear from the docs. Can anyone explain this config option better?
    Thanks

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,801
    Vote Rating
    605
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    paramsAsHash takes all the parameters and sends them off as a JSON object.

    paramOrder defines the order of the params to be sent, eg:

    Code:
    {
        foo: 1,
        bar: 'some value',
        baz: 3
    }
    
    paramOrder: ['baz', 'foo', 'bar']
    So it would be like calling the method:

    Code:
    Foo.MyMethod(3, 1, 'some value');
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Ok, that's pretty clear. But what if a method had no arguments, like in my case? Setting paramsAsHash:true doesn't display the data in my GridPanel, although the data is coming back.

  6. #6
    Ext User
    Join Date
    Jan 2008
    Posts
    7
    Vote Rating
    0
    tuxhero is on a distinguished road

      0  

    Default Example

    Example


    Can u show some example
    Quote Originally Posted by evant View Post
    paramsAsHash takes all the parameters and sends them off as a JSON object.

    paramOrder defines the order of the params to be sent, eg:

    Code:
    {
        foo: 1,
        bar: 'some value',
        baz: 3
    }
    
    paramOrder: ['baz', 'foo', 'bar']
    So it would be like calling the method:

    Code:
    Foo.MyMethod(3, 1, 'some value');

  7. #7
    Sencha User
    Join Date
    Apr 2009
    Location
    Bulgaria
    Posts
    21
    Vote Rating
    1
    ficeto is on a distinguished road

      0  

    Default


    Code:
    if(this.paramOrder){
        for(var i = 0, len = this.paramOrder.length; i < len; i++){
            args.push(params[this.paramOrder[i]]);
        }
    }else if(this.paramsAsHash){
        args.push(params);
    }
    paramsAsHash is true by default
    paramOrder is undefined
    so when you put paramsAsHash:false, you don't add the parameters(limit, start ...) to the arguments(which are []).later on this happens:
    Code:
    args.push(this.createCallback(action, reader, callback, scope, options));
    directFn.apply(window, args);
    which adds object after all the arguments and that is the point where it all goes bad and does not load the request. I moved things around to add the arguments after that object and things show up, but the arguments still don't pass to the directFn (regardless of the form of arguments [arg1,arg2] or {arg1:val1,arg2:val2})....

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi