Sencha Touch: ScriptTagProxy URL for creating / updating

I have a ScriptTagProxy and I can get the data, but now I want to update the record. I provided a url but only one url. Do I have to process all actions (read, update, create, delete) using this URL? If yes: how does the action apply to the url? If not: how can I provide more urls?

Here is the code that I still have:

app.stores.entries = new Ext.data.Store({ model: "app.models.Entry", storeId: 'app.stores.entries', proxy: { type: 'scripttag', url: 'http://myurl.de/getEntries.php', extraParams: { username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username, password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password }, reader: { type: 'json' }, writer: { type: 'json' } } }); 

I read in the docs that you can pass the configuration object to the model save function for proxy settings.

So, I tried the following:

 entry.save({ url: 'http://mysite.com/updateEntry.php', extraParams: { username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username, password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password, entry: entry },} 

As you can see, the URL is provided. But I still get the error: Search error: you are using ServerProxy, but you did not specify it with the url. );

This behavior when using AjaxProxy or RestProxy, for example: (

+1
source share
2 answers

Goering

With the first block of code, you ask:

Question 1) "Do I have to process all the actions (read, update, create, delete) using this URL?"

The answer is yes.

Question 2) "If yes: how does the action apply to the URL?"

According to the Sencha source code, you need to define actionMethods as follows:

 myApp.stores.Things = new Ext.data.Store({ model: "Things", proxy: { type: 'ajax', actionMethods: { create: 'POST', read: 'GET', update: 'PUT', destroy: 'DELETE' }, url: 'jsontest.json', reader: { type: 'json', root: 'things' } }, autoLoad: true 

});

If you delete, create or edit a record, you should call:

store.sync();

There is also an autoSave property, but it only synchronizes when editing, and is not deleted.

This will send for things that have been modified or deleted as part of the request payload, your responsibility is to parse json and process it.

0
source

Goering

I read the documentation here , I found this example in the Model class:

 Ext.regModel('User', { fields: ['id', 'name', 'email'], proxy: { type: 'rest', url : '/users' } }); 

But above you do not show your model for app.models.Entry, have you tried this?

0
source

Source: https://habr.com/ru/post/1435738/


All Articles