ExtJS ext.data.jsonwriter and cakephp

Just spent quite abit of time getting an EditorGrid properly creating and updating rows automagically using Ext Writer. Except it wasn't so magical.
Notes:
- Create requires success: true and then the created record (including the id).
Use this snippet:
echo '{"success":'.$success.', results:'.$javascript->Object($record).'}';
in the above results should be whatever your roots property is in your store reader config. For example:
                reader: new Ext.data.JsonReader({
                        totalProperty: 'total',
                        successProperty: 'success',
                        root: 'results',
                        idProperty: 'id', etc
Example of working create json string:
{"success":true, results:{"id":"47","jobId":"47","jobType":"7",
"partName":"0101012","partDescription":"3.0 Metre Crossover Network Cable",
"quantity":"1","price":"3.5"}}
Example of working update json string:
{success:true, id:11}
After an update you can use $this->MODELNAME->id to get the id for the json.
Destroy just needs
{success:true}
Read example (all records for grid):
{"total":2, "results":[{"id":"46","jobId":"47","jobType":"7",
"partName":"0101104","partDescription":"Dual Back Box","quantity":"1","price":"4.26"},{"id":"47","jobId":"47","jobType":"7",
"partName":"0101012","partDescription":"3.0 Metre Crossover Network Cable","quantity":"1","price":"3.5"}]}
Your rating: None Average: 5 (1 vote)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

What did you do to make

What did you do to make CakePHP eat the JSON Create/Update requests?

Post new comment

The content of this field is kept private and will not be shown publicly.