Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha User
[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:
Code:
proxy: {
type: 'ajax',
api: {
read: '/dime_list',
update: '/dime_update'
},
reader: {
type: 'json',
root: 'items'
}
}
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."
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
-
Can't confirm this on B3 or with the latest code:
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();
});
Please post a test case.
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
-
Sencha User
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:
Code:
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 model definition
Code:
Ext.define('GA.model.Dimension', {
extend: 'Ext.data.Model',
fields: [
'dime_uid',
'dime_desc'
]
});
MVC-like controller definition
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();
}
});
The last line of the updateDimension function should sync the store with the modified record.
-
Still can't confirm on b3:
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();
}
});
If you change the action and refresh you'll see it hits all the correct urls.
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
-
Sencha User
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