PDA

View Full Version : Trouble posting data from a store



grebe
5 Apr 2012, 5:03 AM
Using the example at http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture I cannot get any data posted back to my application. I have worked the example through, and successfully populated the grid from my application (a dot net IHttpHandler). However, when saving changes a request is sent to my application, but there is no posted data. My datastore is as follows:-


Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model : 'AM.model.Users',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: 'users.json',
update: 'updateUsers.json'
},
reader: {
type: 'json',
root: 'users',
successProperty: 'success'
}
}
});


What am I missing?

Update:
I now see the data appears in the Request.InputStream. Is there a way to send this as posted data?

scottmartin
5 Apr 2012, 6:23 AM
Your server should send the updated record back to the client:

pseudo:


function saveRecord() {
// code to save record
...
// return saved record
$data = getRecord($id); // already encoded

$return = array(
'success' => TRUE,
'data' => $data // this should be be data returned from new/updated record in table
);

$return = json_encode($return);
echo $return;
}

function getRecord($id){
// return updated record from table: SELECT FROM ...
}


Regards,
Scott.

grebe
6 Apr 2012, 8:07 AM
Thanks Scott, I now understand I should send the edited record back after updating at the server.

But my issue at present is how to get the data sent to my server in the first place as posted/form data rather than as JSON/XML data (which appears in the request input stream).

scottmartin
7 Apr 2012, 7:10 AM
You can use form.getForm().submit() to send as form data.

Regards,
Scott.