PDA

View Full Version : Proxy Action Method DELETE, PUT, GET



katamshut
13 Sep 2011, 5:49 AM
Hi all

I am very new to sencha and like it much but I have some trouble to understand the proxy use. I have defined the following proxy within my store:


proxy: {
type: 'ajax',
url : 'calendarData.php',
reader: {
type: 'json',
root: 'calendarList'
},
actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
}
}

this all works fine and the client sends a (for example) DELETE request to my php server. I see, that chrome is sending a "request payload" with the record I want to delete. But I cannot access this parameter on server side. So am I doing something totaly wrong?

thx
katam

grubby69
13 Sep 2011, 6:57 AM
I know that if you want to pass some parameters from client to server via a proxy ,you must use 'extraParams' config in the proxy.

for example :


extraParams: {data: variable},

bye

katamshut
13 Sep 2011, 11:56 AM
Yes that's what I did meanwhile..


proxy: {
type: 'ajax',
url : 'calendarData.php',
reader: {
type: 'json',
root: 'calendarList'
}
}

and the controller does:

remove: function(params) {
this.store.proxy.extraParams = {
fromDate: params.record.data.fromDate,
toDate: params.record.data.toDate,
...
action: 'delete'
};
this.store.remove(params.record);
this.store.sync();
this.index();

}

so I am able to pass some parameters... as POST. I use the same FormPanel for INSERT, UPDATE, DELETE action. Isn't there a way to bind the form to my proxy... so I don't have to add every single field to "extraParams" (with this.store.proxy.extraParams = {})?

By the way... I still don't know how to access the browser's "request payload" param on server side (php in my case). Thx as well for any hints on this.

Cheers and Thanks for reply
katam

edspencer
13 Sep 2011, 6:56 PM
Are you tying a Form directly in to a Proxy here? Usually it's easier to just use Ext.Ajax.request with the form element. It's been a while since I had to do this myself but this should work:



var myForm = new Ext.form.FormPanel({...});

Ext.Ajax.request({form: myForm.getEl()});

katamshut
14 Sep 2011, 1:12 PM
thanks ed

see I am just new working with sencha. I did much with jquery in the past but the I wanted to design a small application for me and my friends.. Then I checked out what available frameworks are around and I found Sencha Touch... absolutly best performance of all frameworks... congrats for that and your team. So what I need is to create a calendar tool which simply checks if date ranges are free in the calender and book it. So I just have a list and a form and I do sync all this directly with my php server. So in fact I think I do not need a store here. Anyway I was coming throw a Sencha Touch MVC example.. I coudn't find one which describes the way using a server and no Storage... Now I finally almost reach the goal and finish it...

I think the way you describe is directly use the proxy instance instead of working with a storage, right? I see.

PS. I love my old bro IE6 as well B)