View Full Version : cakephp with Extjs display data in grid - problem in json file

1 Sep 2011, 3:39 AM

I create cakephp with extjs grid view .

For that i create,

1)one movie_controller controller file in which i write

function index() {
$this->recursive = 0;
$this->set('movies', $this->Movie->find("all"));

2)second create index.ctp file in view/movies/index.ctp

<?php echo '{"rows":'.$javascript->Object($movies).'}'; ?>

3)then in js file i call this index.ctp file

not getting data in grid.
when debugging in firebug it's display this array

{"rows":[{"Movie":{"id":"1","date_":"1970-01-01","notes":"Note13455-","asset_id":"1","maint_picture":"","maint_condition1":"Poor","maint_condition2":" New","maint_condition3":"Excellent","maint_condition4":"Good"}},{"Movie":{"id":"2","date_":"2009-03-20","notes":"Note2","asset_id":"1","maint_picture":null,"maint_condition1":"Excellent","maint_condition2":"Excellent","maint_condition3":"New","maint_condition4":"Poor"}}]}

==>In this json file how can i remove Movie array which is display in start all record.

1 Sep 2011, 3:53 PM
Unless I've misunderstood this appears to be a question about PHP, not ExtJS. This is not a suitable forum for asking PHP questions.

29 Mar 2012, 12:40 PM

Your problem is that the cakephp data structure differ from the ExtJS data structure.
You have to transform the data in every request. To transform to your specific example use $movies = Set::extract('/Movie', $movies); as first line in your view.

You also might want to check out Bancha Project, it does all one this automatically
banchaproject.com (http://banchaproject.com)

Best regards