View Full Version : [Solved] problem with a grid

4 Aug 2010, 1:37 AM
Hi !
I have a problem with a grid, it don't print datas and i don't understand why :s
my grid.js


var data = new Ext.data.JsonStore({
id: 'id',
autoDestroy: true,
url: 'get.php',
storeId: 'data',
idProperty: 'id',
root: 'categories',
fields: [
{name:'id', type:'smallint(6)'},
{name:'name', type:'varchar(8)'}

var grid = new Ext.grid.GridPanel({
store: data,
columns: [
{id: 'id', header: 'Identifiant', width: 100, sortable: true, dataIndex: 'id'},
{header: 'Nom ', width: 100, sortable: true, dataIndex: 'name'},
height: 200,
width: 400,
frame: true,
title: 'TEST',
stateful: false,
stateId: 'grid'


render of my get.php

{'categories':[{'id':'1','name':'aaaaaaa'},{'id':'2','name':'bbbbbbbbbbbbb'},{'id':'3','name':'cccccccccccc'},{'id':'4','name':'dddddddddddddd'}]}my get.php

function GetCategoriesJson() {
$query = "SELECT * FROM `categories`";
$categories = array("categories" => array());
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
$categories["categories"][$i] = $row;
return json_encode($categories);

echo GetCategoriesJson();Vince

4 Aug 2010, 1:41 AM
1. This is not an Ext 1.x question, so you posted in the wrong forum.
2. That are not valid field types. Look up the possible types in the API docs.

4 Aug 2010, 2:06 AM
thank for answer and sorry for the wrong forum, can you move the topic ?
but, if i write that :

var data = new Ext.data.JsonStore({
url: 'get.php',
root: 'categories',
fields: ['id', 'name']

it the same problem, an empty grid

4 Aug 2010, 2:30 AM
Are you actually loading the store?


4 Aug 2010, 2:31 AM
i just found that too ^^
thank's for your help !