PDA

View Full Version : Ext.Direct + DirectStore



the7thGhost
29 May 2010, 7:29 PM
Hey all,
In the code below, FireBug shows that it POSTs to router.php, results are shown in the image below. However, calling getCount() on the store returns 0, and the grid has no rows.
What is it that I'm doing wrong? If you need more info, let me know.
Thanks!

Ext Grid:

xtype:'grid',
height: 100,
store: new Ext.data.DirectStore({
storeId: 'CarsStore',
api: {
read: Leo.Car.getList
},
autoLoad: true
}),
columns: [{
header: 'ID',
width: 65,
sortable: true,
dataIndex: 'id'
}, {
header: 'Make',
width: 120,
sortable: true,
dataIndex: 'make'
}, {
header: 'Model',
width: 120,
sortable: true,
dataIndex: 'model'
}, {
header: 'Color',
width: 120,
sortable: true,
dataIndex: 'color'
}]

PHP Function:

class Car {
/**
* @remotable
*/
public function getList() {
return array(
'idProperty' => 'id',
'root' => 'cars',
'totalProperty' => 'results',
'successProperty' => 'success',
'fields' => array(
array('name' => 'id'),
array('name' => 'make'),
array('name' => 'model'),
array('name' => 'color')
),
'sortInfo' => array(
'field' => 'id',
'direction' => 'ASC'
),
'results' => 5,
'success' => true,
'cars' => array(
array(
'id' => 0,
'make' => 'Ford',
'model' => 'Focus',
'color' => 'Blue'
),
array(
'id' => 1,
'make' => 'Ford',
'model' => 'Focus',
'color' => 'Black'
),
array(
'id' => 2,
'make' => 'Ford',
'model' => 'Focus',
'color' => 'Red'
),
array(
'id' => 6,
'make' => 'Nissan',
'model' => 'Altima',
'color' => 'Steel Blue'
),
array(
'id' => 7,
'make' => 'Nissan',
'model' => 'Altima',
'color' => 'Silver'
)
)
);
} //eo function getList
}

http://i801.photobucket.com/albums/yy298/the7thGhost/th_json.png (http://s801.photobucket.com/albums/yy298/the7thGhost/?action=view&current=json.png)