1. #1
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Rio de Janeiro, Brazil
    Posts
    12
    Vote Rating
    0
    stefanosandes is on a distinguished road

      0  

    Question dataStore response after sending to server (store.save)

    dataStore response after sending to server (store.save)


    Hello!

    I have a code that sends data from one grid to the server.
    Everything works fine, but do not know how to get the server response.

    Can you help me?
    Thanks!


    PHP Code:
    var writer = new Ext.data.JsonWriter({
            
    encodetrue

        
    });

        var 
    Cr Ext.data.Record.create([
            { 
    name'DE_CD_UNIDADE' },
            { 
    name'VL_PRECO' },
            { 
    name'VL_DECORACAO' }

        ]);

        var 
    reader = new Ext.data.JsonReader(
            {
                
    root'data',
                
    messageProperty'message'
            
    }, Cr
            
    );

        var 
    proxy = new Ext.data.HttpProxy({
            
    api: {
                
    create'_CODE/ASPX/_tabvendas/_tab_venda_importacao.aspx'
            
    }
        });

        var 
    dsTabVendaImportacao = new Ext.data.Store({
            
    proxyproxy,
            
    readerreader,
            
    writerwriter,
            
    autoLoadfalse,
            
    autoSavefalse,
            
    baseParams: { cdEmpreendimentocdEmpreendimentocdBlococdBlococdTabelacdTabela },
            
    listeners: { 'add': function () {
                if (
    this.getCount() > 0) {
                    
    Ext.getCmp('btnSalvar').enable();
                } else {
                    
    Ext.getCmp('btnSalvar').disable();
                }
            }
            }
        });

        
    Win = new Ext.Window({
            
    titleTit
            
    width450
            
    height220
            
    layout'fit'
            
    modaltrue
            
    items: [
                new 
    Ext.grid.GridPanel({
                    
    borderfalse
                    
    storedsTabVendaImportacao
                    
    triggerAction'all'
                    
    stripeRowstrue
                    
    plugins: [Ext.ux.grid.DataDrop]
                    , 
    columns: [{
                        
    dataIndex'DE_CD_UNIDADE'
                          
    header'Unidade'
                          
    sortabletrue
                          
    width100
                    
    }, {
                        
    xtype'numbercolumn'
                          
    dataIndex'VL_PRECO'
                          
    header'Preço'
                          
    sortabletrue
                          
    width100
                          
    format'R$ 0,0.00'
                    
    }, {
                        
    xtype'numbercolumn'
                          
    dataIndex'VL_DECORACAO'
                          
    header'Valor de Decoração'
                          
    sortabletrue
                          
    width100
                          
    format'R$ 0,0.00'
                    
    }]
                })],
            
    fbar: {
                
    xtype'toolbar',
                
    items: [{
                    
    xtype'button'
                      
    text'Salvar'
                      
    id'btnSalvar'
                      
    iconCls'icl-save'
                      
    disabledtrue
                      
    handler: function () {
                          
    dsTabVendaImportacao.save();
                      }
                }, {
                    
    xtype'button'
                      
    text'Cancelar'
                      
    iconCls'icl-canc'
                      
    handler: function () {
                          
    Win.close();
                      }
                }]
            }
        }).
    show(); 

  2. #2
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    Hi,

    Listen to the 'write' event of the store.

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Rio de Janeiro, Brazil
    Posts
    12
    Vote Rating
    0
    stefanosandes is on a distinguished road

      0  

    Default


    I tried using the event "write", but not passed by the event.

    I used:

    PHP Code:
    listeners: ('write': function ()
    {
            
    alert ('hello')
    }

    Did not work.

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    When listening to the Ext.data.Store's write event, the data param will contain the content of the 'data' property of the object created from the server response. If you want to retrive the whole data returned by the server, I think you have to listen to the write event of the Ext.data.DataProxy encapsulated in the store.

    E.g.

    Code:
    store.proxy.on('write', function(store, action, data, response) {
       console.log(response);
     });

  5. #5
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Rio de Janeiro, Brazil
    Posts
    12
    Vote Rating
    0
    stefanosandes is on a distinguished road

      0  

    Default


    scarsick,

    I tested your solution, but without success.

    It may be some problem in json format of my reply?
    The server returns: '{success: true}'.

    Thanks!

  6. #6
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Rio de Janeiro, Brazil
    Posts
    12
    Vote Rating
    0
    stefanosandes is on a distinguished road

      0  

    Default


    The event 'exception' is called, but 'write' no.

    Firebug by the server is returning 200.
    The code on the server side is perfect.

    Any solution?
    I am using Asp.net.

  7. #7
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    Well, if the exception event is called, write event won't be called, obviously hehe. If the server returns 200 and exception event is fired, it means that the store reader did not succeed in parsing the value returned by the server.
    Log the 'arg' argument passed to the exception event handler function, it should be a javascript Error object. You will then be able to see why the parse failed. But before doing this, I suggest that you add message: "" to your json response, I think it is mandatory to have it.

    exception : ( DataProxy this, String type, String action, Object options, Object response, Mixed arg )

    E.g. server response:

    Code:
     
    { "success": true, "message": "" }

  8. #8
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Rio de Janeiro, Brazil
    Posts
    12
    Vote Rating
    0
    stefanosandes is on a distinguished road

      0  

    Default


    Well, if the exception event is called, write event won't be called, obviously hehe
    Sorry, my English is not good. hehe.

    There is no error by the server or the formed JSON returned, sure.

    I managed to get the response from the server within the "exception". From what I understand, for the event to "write" sech called I have to return the data that was sent from my datastore. In this example: http://dev.sencha.com/deploy/dev/exa...l/restful.html

    Thanks for your help!

Similar Threads

  1. Store save with server-side validation errors
    By NicoCipo in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 15 Mar 2011, 10:55 AM
  2. Editor Grid: how to handle server response when click on "Save" button
    By Deeeem in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 13 Jul 2010, 7:28 AM
  3. Getting server response on datastore loadexception
    By mad_ady in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 14 Mar 2010, 10:53 PM
  4. Sending Multiple Response with 1 call to server
    By ektanit in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 14 May 2009, 9:55 AM
  5. Is it possible to change response from server before storing into Datastore?
    By Cyberangel67 in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 9 Aug 2007, 7:56 AM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar