PDA

View Full Version : JsonStore and GridPanel



ornanong_o
30 Sep 2010, 12:35 AM
var store = new Ext.data.JsonStore({
url: "services/node/untitled1/1234"
});
var gridPanel = new Ext.grid.GridPanel({
id: id,
title: id,
closable: true,
store: store,
columns: [{
header: "Name",
dataIndex: 'name'
}, {
header: "Value",
dataIndex: 'value'
}]

});
store.load();
I have retrieved json data from server and json data look like this :


{
"name":"a",
"id":"1234",
"type":"class",
"visibility":"public"
}
How can I create GridPanel which data like this:
22626

laurentParis
30 Sep 2010, 12:44 AM
var store = new Ext.data.JsonStore({
url: 'services/node/untitled1/1234',
root: 'datas',
fields: ['name', value']
});
var gridPanel = new Ext.grid.GridPanel({
title: 'title',
closable: true,
store: store,
columns: [{
header: "Name",
dataIndex: 'name'
},
{
header: "Value",
dataIndex: 'value'
}]
});
store.load();


your datas from server must be like that


{datas: [{name: 'Name', value: 'A'}, {name: 'Id', value: '1234'}, {name: 'Type', value: 'class'}, {name: 'Visibility', value: 'public'}]}

ornanong_o
30 Sep 2010, 12:49 AM
Can I use this json format ??



{
"name":"a",
"id":"1234",
"type":"class",
"visibility":"public"
}

Animal
30 Sep 2010, 12:55 AM
That's a PropertyGrid

ornanong_o
30 Sep 2010, 1:23 AM
How can I add more column to PropertyGrid (name, value, Catagory)

Thanks for your answer

Animal
30 Sep 2010, 1:25 AM
Anything wrong with the docs?

http://dev.sencha.com/deploy/ext-3.3-beta1-6976/docs/?class=Ext.grid.PropertyStore

If you find any mistakes in there, they can be fixed.

m4eclipse
30 Sep 2010, 1:46 AM
I am not sure but I think you can use the property panel http://awesomescreenshot.com/0e41vu0c0
(http://awesomescreenshot.com/0e41vu0c0)

ornanong_o
30 Sep 2010, 2:30 AM
Sorry I'm new for ExtJS, please provide sample code for load data from service and parse to PropertyGrid. (which like to use jsonStore and GridPanel) and sample code for add column to PropertyGrid.

ornanong_o
1 Oct 2010, 12:28 AM
Anything wrong with the docs?

http://dev.sencha.com/deploy/ext-3.3-beta1-6976/docs/?class=Ext.grid.PropertyStore

If you find any mistakes in there, they can be fixed.


How can I use PropertyStore to add column to PropertyGrid like this :
22652

Animal
1 Oct 2010, 1:04 AM
That gets beyond being a PropertyGrid.

Just create a GridPanel, and transform your data into a regular readable format yourself.