-
23 Apr 2011 8:23 AM #1
[INFOREQ]api assignment in AjaxProxy
[INFOREQ]api assignment in AjaxProxy
Hi,
I am trying to use the AjaxProxy with the "api" config option to support different store URL's for reading and updating.
I use it this way:
Reading works well but in case of an update I've got an error: "You are using a ServerProxy but have not supplied it with a url."Code:proxy: { type: 'ajax', api: { read: '/dime_list', update: '/dime_update' }, reader: { type: 'json', root: 'items' } }
Does anybody know the reason for that behaviour?
Another confusing thing I have found in the documentation. The doc of the class AjaxProxy (config option "api") says that there are the following actions available "read, create, update, destroy". A paragraph below there are the following actions mentioned "load, create, save, destroy". Which are correct?
Cheers,
Oliver
-
23 Apr 2011 8:09 PM #2
Can't confirm this on B3 or with the latest code:
Please post a test case.Code:Ext.require('Ext.data.*'); Ext.define('Foo', { extend: 'Ext.data.Model', fields: ['a'] }); Ext.onReady(function(){ var store = Ext.create('Ext.data.Store', { proxy: { type: 'ajax', api: { read: '/dime_list', update: '/dime_update' }, reader: { type: 'json', root: 'items' } } }); store.load(); });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
23 Apr 2011 11:06 PM #3
In your example you only reading the store. Reading is also possible in my case. The problem occurs on updating the store.
MVC-like store definition:
MVC-like model definitionCode:Ext.define('GA.store.Dimensions', { extend: 'Ext.data.Store', model: 'GA.model.Dimension', autoLoad: true, proxy: { type: 'ajax', api: { read: '/jaavoPaperdocs/frontend/dyn/dime_list', update: '/jaavoPaperdocs/frontend/dyn/dime_list' }, reader: { type: 'json', root: 'items' } } });
MVC-like controller definitionCode:Ext.define('GA.model.Dimension', { extend: 'Ext.data.Model', fields: [ 'dime_uid', 'dime_desc' ] });
The last line of the updateDimension function should sync the store with the modified record.Code:Ext.define('GA.controller.Dimensions', { extend: 'Ext.app.Controller', stores: ['Dimensions'], models: ['Dimension'], init: function() { this.control({ 'dimensionlist': { itemdblclick: this.editDimension }, 'dimensionedit button[action=save]': { click: this.updateDimension } }); }, editDimension: function(grid, record) { var view = Ext.create('GA.view.dimension.Edit'); view.down('form').loadRecord(record); }, updateDimension: function(button) { var window = button.up('window'); form = window.down('form'); record = form.getRecord(); values = form.getValues(); record.set(values); window.close(); this.getStore('Dimensions').sync(); } });
-
24 Apr 2011 1:27 AM #4
Still can't confirm on b3:
If you change the action and refresh you'll see it hits all the correct urls.Code:Ext.require('Ext.data.*'); Ext.define('Foo', { extend: 'Ext.data.Model', fields: ['a'] }); Ext.onReady(function(){ var action = 'update', item; var store = Ext.create('Ext.data.Store', { model: 'Foo', proxy: { type: 'ajax', api: { read: 'foo.json?read=true', update: 'foo.json?update=true', create: 'foo.json?create=true', destroy: 'foo.json?destroy=true' }, reader: { type: 'json', root: 'items' } } }); if (action == 'read') { store.load(); } else if (action == 'destroy') { item = new Foo({ a: 'a' }, 1); store.add(item); store.remove(item); store.destroy(); } else if (action == 'create') { store.add(new Foo({ a: 'a' }, 1)); store.create(); } else if (action == 'update') { var item = new Foo({ a: 'b' }, 1); store.add(item); item.set('a', 'c'); store.save(); } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
4 Jul 2011 10:08 AM #5
I have the same issue
I have the same issue
I'am using the api in store:
Ext.define('ICEISI.ADM.store.Usuarios',{
extend: 'Ext.data.Store',
model: 'ICEISI.ADM.model.Usuario',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: '/gerenciar-usuario/listar/format/json',
update: '/gerenciar-usuario/atualizar/format/json'
},
reader: {
type: 'json',
root: 'dados',
successProperty: 'success'
}
}
});
And get the issue when update the store: uncaught exception: You are using a ServerProxy but have not supplied it with a url.
The code that update store is:
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
this.getStore('Usuarios').sync(); // Here the store is update
win.close();
I think this is an Bug
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[2.2] IE 7 Error with cssText assignment
By nak1 in forum Ext 2.x: BugsReplies: 4Last Post: 6 Dec 2012, 3:13 AM -
AjaxProxy
By vmadman in forum Ext: DiscussionReplies: 4Last Post: 9 Aug 2011, 11:27 PM -
AjaxProxy on failure
By h4m1d.r3z4 in forum Sencha Touch 1.x: DiscussionReplies: 0Last Post: 30 Jan 2011, 2:50 AM -
[OPEN-669] wrong assignment x-item-selected class on list with itemSelector
By wakatanka in forum Sencha Touch 1.x: BugsReplies: 0Last Post: 16 Dec 2010, 2:08 AM


Reply With Quote