PDA

View Full Version : How to post data?



wallynm
22 Nov 2011, 5:21 AM
Hey guys, i'm trying to update an grid, which form is inside an window. Here's my controller code which send the Ajax request:


updateUser: function(button) {
var win = button.up('window');
var form = win.down('form');
var record = form.getRecord();
var values = form.getValues();
console.error(record, values)
record.set(values);
win.close();
this.getTarefasTesteStore().sync()
}



Well, my problem here, it's because, .sync() send an ajax request, but i don't know how to get the data on the server, my store:


Ext.define('taskmag.store.TarefasTeste', { extend: 'Ext.data.Store',
model: 'taskmag.model.Tarefas',
autoLoad: true,
//autoSync: true,
pageSize: 20,
proxy: {
method: 'POST',
type: 'ajax',
actionMethods: {read : 'POST'},
api: {
read: baseurl+'tarefas/listagem',
update: baseurl+'tarefas/update'
},

reader: {
type: 'json',
root: 'rows',
totalProperty: 'total'
}
}
});

I could pass all the data inside my form to the update URL?
How i would pass it as POST data?


My ajax send has an request payload, which is the row edited, i would like to get this data as post data...


Query String
_dc: 1321966762541

Request Payload
{"codtarefa":"4","nometarefa":"Cadastro de sistema","codcriador":"1","codresponsavel":"1","datainicio":"11/26/2011","datacriacao":"11/26/2011","datafinalizacao":"11/26/2011","status":"4"}

wallynm
22 Nov 2011, 9:01 AM
I have found an way to perform actions on the server, using Ajax request and submit on the form setting the url parameter, but i was wondering what the api config on the proxy definitions do in the system???


proxy: {
idProperty: 'codtarefa',
method: 'POST',
type: 'ajax',
actionMethods: {read : 'POST'},
api: {
read: baseurl+'tarefas/listagem',
update :baseurl+'tarefas/listagem',
}

If i use store.sync() the update url it's called, but it don't send ANY POST data, so i cant update anything on the server, so, if it calling sync() method, what are the api purpose???