1. #21
    Sencha User
    Join Date
    Jul 2012
    Posts
    14
    Vote Rating
    1
    alexandrn is on a distinguished road

      0  

    Default


    for full completness, could you please also update the first part of the code with additional block that creates a new model/record from the form and saves it.

  2. #22
    Sencha User olecom's Avatar
    Join Date
    Oct 2011
    Location
    Republic of Belarus
    Posts
    27
    Vote Rating
    1
    olecom is on a distinguished road

      0  

    Default


    i use patched AbstactStore.sync() as mentioned
    PHP Code:
    var lm = new Ext.LoadMask(Ext.sheets.pasteSMS, {msg:'processing rows...'}) 
    PHP Code:
            ,dockedItems: [{
                
    xtype'toolbar',
                
    items: [
                { 
    text:'Add row'
                    
    ,iconCls:'addrow'
                    
    ,handler: function(be) {
                        
    Ext.getStore('smspasteS').add({})
                        
    b.up('toolbar')
                        
    b.getComponent('addsmsq').enable()
                        
    b.getComponent('rmsmsq').enable()
                    }
                },{
                    
    itemId'addsmsq'
                    
    ,text:'Append rows into send queue'
                    
    ,iconCls:'add'
                    
    ,disabled: !true
                    
    ,handler: function(bsv){
            
    b.up('gridpanel')
            
    s.getView()
    0)        lm.show()
            
    s.getStore()
            if(!
    s.sync({
                
    success: function(batchopts){
                    
    app_tabs.setActiveTab('sendqinfo')
                    
    opts s.getProxy().getReader().rawData
    Ext
    ._log('smsq add OK data.length: ' opts.data.length)
                    
    opts opts.total pageSize
                    v
    .onCellSelect({ row:,column:})
                    
    v.onCellDeselect({ row:,column:})
                    
    s.removeAll()
                    
                    
    Math.floor(opts//load last page 
                     
    Ext.getStore('taq').loadPage(opts s,{ //mongo db 
                        
    callback: function(recordsoperationsuccess) {
                            if(!
    successExt.Msg.alert({iconExt.Msg.ERROR ,buttonsExt.Msg.OK
                            
    ,title:"Send Queue" ,msg:"Error loading from remote server!"})
                        }
                    })
                     
    b.up('toolbar').getComponent('rmsmsq').disable()
    1)                lm.hide()
                }
                ,
    failure: function(batchopts){
    2)                lm.hide()
                    
    Ext.Msg.alert({ title:"Send Queue" ,iconExt.Msg.ERROR ,buttonsExt.Msg.OK
                        
    ,msg:"Serious error processing append operation."})
                }
            })) { 
    //sync
    3)            lm.hide()
                
    Ext.Msg.alert({iconExt.Msg.INFO ,buttonsExt.Msg.OK
                
    ,title:"Send Queue" ,msg:"Nothing to append!"})
            }
                    }
                }
    ​ 

  3. #23
    Sencha Premium Member dawesi's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia (aka GMT+10)
    Posts
    1,083
    Vote Rating
    44
    dawesi has a spectacular aura about dawesi has a spectacular aura about

      0  

    Default


    The answer from http://stackoverflow.com/questions/1...tosync-enabled


    Code:
    Ext.define('BS.store.Users', {
        extend: 'Ext.data.Store',
        model: 'BS.model.User',
    
        autoSync: true,
        autoLoad: true,
    
        proxy: {
            type: 'direct',
            api: {
                create: Users.Create,
                read: Users.Get,
                update: Users.Update,
                destroy: Users.Delete,
    
            },
            reader: {
                type: 'json',
                root: 'data',
            },
        },
    
        onCreateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onUpdateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onDestroyRecords: function(records, operation, success) {
            console.log(records);
        },
    
    });
    Teahouse Training Company
    Official Certified Sencha Trainer

    Australia / New Zealand / Singapore / Hong Kong & APAC



    SenchaWorld.com - Sencha webinars, videos, etc
    SenchaForge.org - (coming soon)
    TeahouseHQ.com - Sencha ecosystem training portal

    Code Validation : JSLint | JSONLint | JSONPLint

  4. #24
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    51
    Vote Rating
    3
    extjs@kingsquare.nl is on a distinguished road

      0  

    Post My fix

    My fix


    The only way i could think of to get some kind of reference to the responsebody in case of failure:

    Code:
    Ext.override(Ext.data.proxy.Server, {
    	processResponse: function (success, operation, request, response, callback, scope) {
    		//create a reference to the response in the only passed paramter to the callback
    		operation.response = response;
    		this.callParent(arguments);
    	}
    });
    Now, the response can be processed as follows:

    Code:
    record.save({
    	success: function (record, operation) {
    		...
    	},
    	failure: function (record, operation) {
    		console.log('failure', operation.response.responseText);
    	}
    });

  5. #25
    Sencha User
    Join Date
    Apr 2011
    Posts
    4
    Vote Rating
    0
    martins256 is on a distinguished road

      0  

    Default


    Here is what worked for me. Instead of submiting form I am saving record. If an error occurs on the server then error messages are loaded into the form.

    Code:
    record.set(values);
    record.save({
        success: function(record, operation){
            store.add(record);
            win.close();
        },
        failure: function(record, operation){
            var errors = operation.request.scope.reader.jsonData.errors;
            form.getForm().markInvalid(errors);
        }
    });

  6. #26
    Sencha User
    Join Date
    Apr 2013
    Posts
    7
    Vote Rating
    0
    Alex_Dutch is on a distinguished road

      0  

    Default api store

    api store


    But how to catch an errors then use api: read, create, update

    Code:
    proxy: {
            type: 'ajax',
            api: {
                read: 'data/readUserVault.php',
                update: 'data/updateVault.php',
                create: 'data/createVault.php',
                destroy: 'data/deleteVault.php'
            },
            reader: {
                type: 'json',
                root: 'data',
                successProperty: 'success'
            },
            writer: {
                type: 'json',
                root: 'data',
                encode: true
            }
    }

  7. #27
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    2
    ejerrywest is on a distinguished road

      0  

    Default


    I also needed to get the response on sync success. This is how I handled it in 4.2:

    Code:
        store.sync({
            success: function(batch) {
                console.log(batch.proxy.reader.jsonData);
            }
        });
    It will work the same for failure handler.

  8. #28
    Ext JS Premium Member
    Join Date
    Feb 2010
    Posts
    29
    Vote Rating
    1
    ogimenezb is on a distinguished road

      0  

    Default


    I'm using this:

    Code:
                    Ext.override(Ext.data.proxy.Server, {
                        setException: function(operation, response){
                            operation.response = response;
                            operation.responseText = response.responseText;
                            operation.responseData = Ext.JSON.decode(operation.responseText);
                            operation.setException({
                                status: response.status,
                                statusText: response.statusText
                            });
                        }
                    });

  9. #29
    Sencha User
    Join Date
    May 2009
    Posts
    4
    Vote Rating
    1
    miisha is on a distinguished road

      0  

    Default


    Setting messageProperty for reader worked for me (tested on version 4.1.1 GPL):
    PHP Code:
        proxy: {
            
    type'ajax',
            
    api: {            
                
    read'my_r.php',
                
    update'my_u.php'
            
    }, reader: {  
                
    type'json',
                
    root'data'
                
    messageProperty'error'
            
    }
        } 
    When server response is something like:
    Code:
    {"success":false,"error":"My error"}
    Then I can access this error using error property of operation object:
    PHP Code:
            me.record.save({
                
    callback: function(recs,op,success){
                    if(!
    success){
                        
    Ext.Msg.alert('Error',op.getError());
                    }
                }
            }) 

  10. #30
    Sencha User
    Join Date
    Apr 2014
    Posts
    3
    Vote Rating
    0
    undisencha is on a distinguished road

      0  

    Default It worked

    It worked


    Its works for me and thank you very much for posting this. I was searching for this kind for past two days. Finally I got the answer. Really thank full to you.

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