1. #1
    Ext User
    Join Date
    Jun 2008
    Location
    Saltillo, México!
    Posts
    12
    Vote Rating
    0
    migolo is on a distinguished road

      0  

    Arrow [3.1] Direct Store with API, Update action takes no parameters

    [3.1] Direct Store with API, Update action takes no parameters


    Hi again.

    I configured a Direct Store with API actions, in Ext 3.0 everything was working perfectly, when I upgraded to 3.1, the "update" action isn't sending the parameters:

    Here is the Request payload with version 3.1:

    HTML Code:
    {"action":"Productos","method":"modificar","data":[],"type":"rpc","tid":11}
    And the response:
    HTML Code:
    {"type":"exception","tid":11,"message":"Not enough required params specified for method: modificar on class Productos"}
    In version 3.0.0 the Request payload is:

    HTML Code:
    {"action":"Productos","method":"modificar","data":["3","{\"id\":\"3\",\"nombre\":\"Tangram 1, aktuell Lektion 5-8\",\"precio\":481,\"cantidad\":\"5\"}"],"type":"rpc","tid":10}


    And the response is:
    HTML Code:
    {"type":"rpc","tid":10,"action":"Productos","method":"modificar","result":{"id":"3","nombre":"Tangram 1, aktuell Lektion 5-8","precio":481,"cantidad":5}}



    I am using the same application only testing with the newer version, this is how I configured the store and was working in version 3.0.0 and isn't in 3.1
    HTML Code:
     var productos_writer = new Ext.data.JsonWriter({
        writeAllFields: true // write all fields, not just those that changed
    });
    
    Productos = new Ext.data.DirectStore({
        api: {
            read: Migolo.Productos.listar,
            update: Migolo.Productos.modificar
        },
        paramOrder: ['buscar','start'],
        baseParams: {
            buscar: ""
        },
        autoLoad: true,
        root: "data",
        reader: new Ext.data.JsonReader({
            totalProperty: 'totalCount',
            idProperty: 'id',
            root: 'data'
        }, [{
            name: 'id',
            mapping: 'id'
        },{
            name: 'nombre',
            mapping: 'nombre'
        },{
            name: 'precio',
            mapping: 'precio'
        },{
            name: 'cantidad',
            mapping: 'cantidad'
        }]),
        writer: productos_writer
    });



    I must say that the "read" action is working in both versions sending the right params.

    Best regards, and sorry for my English.

    Miguel González

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

      0  

    Default


    Hi Miguel, I am also experiencing the same issue.

    The 'update' action is firing but with empty data (It was working in 3.0.3).

    I do not know why however...

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

      0  

    Default


    I tracked down the problem and it seems to occur in the save method of the Ext.data.Store class definition (around line 20125):
    Code:
            len = queue.length;
            if(len){
                batch = ++this.batchCounter;
                for(var i = 0; i < len; ++i){
                    trans = queue[i];	
                    console.debug(trans); // #### ADDED THIS
                    data[trans[0]] = trans[1];
                }
    console.debug(data); // #### ADDED THIS
                if(this.fireEvent('beforesave', this, data) !== false){
                    for(var i = 0; i < len; ++i){
                        trans = queue[i];
                        this.doTransaction(trans[0], trans[1], batch);
                    }
                    return batch;
                }
            }
    When testing within my own program:
    trans contains the following array:
    Code:
    ["update", [Object {  id="3855",  more...}]]
    However, it seems like data[trans[0]] = trans[1]; is not working since when I output data, I get the following:
    Object { update=}
    As if trans[1] was empty

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    87
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Quote Originally Posted by vinnybozz View Post
    When testing within my own program:
    trans contains the following array:
    Code:
    ["update", [Object {  id="3855",  more...}]]
    However, it seems like data[trans[0]] = trans[1]; is not working since when I output data, I get the following:
    Object { update=}
    As if trans[1] was empty
    That's just a display error in Firebug.

    Try using:
    Code:
    console.dir(data);

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

      0  

    Default


    Hi Condor, you're right, the data object now seems to contain the correct information.

    The data is still not being sent though, I'll keep trying to find something (using console.dir now !! )

  6. #6
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    This works in 3.1.x:
    Code:
      var writer = new Ext.data.JsonWriter
      ({
        encode: false,  // Very important, defaults to true
        writeAllFields : true
      });
      var reader = new Ext.data.JsonReader
      ({
        root            : 'records',
        idProperty      : 'event_person_id',
        totalProperty   : 'totalCount',
        successProperty : 'success',
        messageProperty : 'message',
        
        fields          : recordFields
      });
      var proxy = new Ext.data.DirectProxy
      ({
        api :
        {
          read:   Zayso.Direct.Event_EventPerson.read,
          create: Zayso.Direct.Event_EventPerson.create,
          update: Zayso.Direct.Event_EventPerson.update
        },
        paramsAsHash: true
      });
      var gridStore = new Ext.data.DirectStore
      ({
        // These all come from Store
        storeId     : 'referee-signup-grid-store',
        baseParams  : { event_id : this.eventId, base2: 'somthing' },
        autoLoad    : false,
        autoSave    : false,
        
        remoteSort  : false,
        sortInfo    : { field : 'position_id', direction : 'ASC'},
        
        writer      : writer,
        reader      : reader,
        proxy       : proxy
      });
    Try setting encode to false.

    And I always use paramsAsHash which ends up sending all the parameters in one array. The direct functions use a len of 1.

  7. #7
    Ext User
    Join Date
    Jun 2008
    Location
    Saltillo, México!
    Posts
    12
    Vote Rating
    0
    migolo is on a distinguished road

      0  

    Default


    Hi again,

    Cerad, compring your code, I changed the writer to do an encode: false, and yes, it sends the data, so i think there is a problem with the encode function because I tried setting it to true and the update function sent empty data.

  8. #8
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    Unless you have a burning desire to encode the data then just leave it false.

  9. #9
    Ext User
    Join Date
    Jun 2008
    Location
    Saltillo, México!
    Posts
    12
    Vote Rating
    0
    migolo is on a distinguished road

      0  

    Default


    I can manage that, a thing I didn't saw before is that the request is sent in a different way:

    I get this:
    HTML Code:
    {"action":"Productos","method":"modificar","data":[{"buscar":"","data":{"id":"3","nombre":"Tangram  1, aktuell  Lektion 5-8","precio":480,"cantidad":"5"}}],"type":"rpc","tid":10}
    Instead of this:
    HTML Code:
    {"action":"Productos","method":"modificar","data":["3","{\"id\":\"3\",\"nombre\":\"Tangram 1, aktuell Lektion 5-8\",\"precio\":480,\"cantidad\":\"5\"}"]
    ,"type":"rpc","tid":10}
    I only added the encode: false
    Last edited by migolo; 25 Jan 2010 at 8:33 PM. Reason: Formatting

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..."