-
6 Sep 2012 2:39 PM #21
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.
-
7 Sep 2012 12:38 PM #22
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(b, e) {
Ext.getStore('smspasteS').add({})
b = 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(b, s, v){
s = b.up('gridpanel')
v = s.getView()
0) lm.show()
s = s.getStore()
if(!s.sync({
success: function(batch, opts){
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:0 ,column:0 })
v.onCellDeselect({ row:0 ,column:0 })
s.removeAll()
s = Math.floor(opts) //load last page
Ext.getStore('taq').loadPage(opts - s ? s + 1 : s,{ //mongo db
callback: function(records, operation, success) {
if(!success) Ext.Msg.alert({icon: Ext.Msg.ERROR ,buttons: Ext.Msg.OK
,title:"Send Queue" ,msg:"Error loading from remote server!"})
}
})
b.up('toolbar').getComponent('rmsmsq').disable()
1) lm.hide()
}
,failure: function(batch, opts){
2) lm.hide()
Ext.Msg.alert({ title:"Send Queue" ,icon: Ext.Msg.ERROR ,buttons: Ext.Msg.OK
,msg:"Serious error processing append operation."})
}
})) { //sync
3) lm.hide()
Ext.Msg.alert({icon: Ext.Msg.INFO ,buttons: Ext.Msg.OK
,title:"Send Queue" ,msg:"Nothing to append!"})
}
}
}
-
25 Sep 2012 5:19 PM #23Sencha - Sales Team
- Join Date
- Mar 2007
- Location
- Melbourne, Australia (aka GMT+10)
- Posts
- 753
- Vote Rating
- 6
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); }, });Sencha Technical Sales & Senior Technical Trainer
Sencha Inc
Register with discount code "ASA357" and save $100

The new SenchaWorld.com is coming in July, more details closer to SenchaCon
Code Validation : JSLint | JSONLint | JSONPLint
-
10 Jan 2013 8:42 AM #24
My fix
My fix
The only way i could think of to get some kind of reference to the responsebody in case of failure:
Now, the response can be processed as follows: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); } });
Code:record.save({ success: function (record, operation) { ... }, failure: function (record, operation) { console.log('failure', operation.response.responseText); } });
-
27 Feb 2013 1:31 AM #25
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); } });
-
19 Apr 2013 11:06 AM #26
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 } }


Reply With Quote


