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:
After an update you can use $this->MODELNAME->id to get the id for the json.
Destroy just needs
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"}]}
Bookmark/Search this post with
Comments
The idea of "distributions"
The idea of "distributions" and "projects" doesn't appeal very much to me, at least if I am not sure that after installing that distribution I still have a standard Drupal installation with which i can do whatever I like. This is why I have never considered Open Publish or Tattler, at least not for flexible projects that need customization. Perhaps if I had one specific project (like an online journal) and I found a perfect distribution for my project I would use it, but not as a customizable solution for a varied community...
E22-275 exam | 1z0-052 exam | 650-369 exam | 70-663 exam | 70-536 exam | 650-295 exam | 1Y0-A05 exam | LX0-101 exam |-----------------------------
gridpanel with dynamic column
I am trying to get the grid panel on the bases of Json response. My intention is that what are the fields available in the json response, according to that the grid panel needs to create. so in that case i dont have to declare fields in the new Ext.data.JsonReader({}). Here is my script
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'http://localhost/cake129/admin/'+ids[n.id]+'/getall'+ids[n.id]+'/'}),
reader: new Ext.data.JsonReader({
root: 'users',
totalProperty: 'total',
fields: [/* instead of writing fields explicitly it should take dynamically as per Json response
{name: 'id'},
{name: 'firstname'},
{name: 'lastname'},
{name: 'email'},
{name: 'created', type: 'date', dateFormat: 'Y-m-d H:i:s'},
{name: 'modified'},
{name: 'active'},
{name: 'confirm'}*/
]
})
});
//This is the column model. This defines the columns in my datagrid.
//It also maps each column with the appropriate json data from my database (dataIndex).
var cm = new Ext.grid.ColumnModel([
/*{header: "ID", dataIndex: 'id', width: 40, hidden: true},
{header: "First Name", dataIndex: 'firstname', width: 116,hidden: false,sortable: true},
{header: "Last Name", dataIndex: 'lastname', width: 110,hidden: false,sortable: true},
{header: "E-Mail", dataIndex: 'email', width: 200,hidden: false,sortable: true},
{header: "Created", dataIndex: 'created', width: 150,hidden: false},
{header: "Modified", dataIndex: 'modified', width: 150,hidden: false},
{header: "Active", dataIndex: 'active', width: 55,hidden: false},
{header: "Confirm", dataIndex: 'confirm', width: 50,hidden: true}*/
]);
//Here's where we define our datagrid.
//We have to specify our dataStore and our columnModel.
var grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
stripeRows: true,
height:300,
width:870,
title: ''+ids[n.id]+'',
/*autoScroll: true,
autoHeight: true*/
stripeRows: true
});
Can anybody help me ?
Thanks
What did you do to make
What did you do to make CakePHP eat the JSON Create/Update requests?
Post new comment