PDA

View Full Version : JSON vs Gris vs Date



666ragez666
22 Jan 2009, 6:34 PM
Hi All,

I am a new user to GXT but have been around with ext since half year. First I would like to say I really appreciate your work so keep amaze me! :D

That said, I have a little problem with loading some date in a grid, I am using JSON for that purpose.

Can someone can provide a snippet of a JSON resultset and the code to properly display it in a grid, it would be greatly appreciated?

666ragez666
22 Jan 2009, 7:05 PM
on the same fashion any snippet of a grid with both paging and grouping feature ?

gslender
22 Jan 2009, 9:15 PM
most examples/snippets are found here -> http://extjs.com/examples/

666ragez666
22 Jan 2009, 9:52 PM
Hi Gslender,

Yeah I have been looking to that and particulary the mail and explorer sample to get started. But I still feel there is still some missing stuff compare to the example set of Ext JS. But I am pretty sure you are hard working to fill the gap.

BTW I wasn't able to find any exemple using both a Date field in a grid loaded via JSON. Right now if I try to use the


startDateConfig.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));
endDateConfig.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

I get some cast error String (or Double) to Date .... so means somehow the grid end up loading a string and not a date.

my JSON look like this :

{
'results': 4,
'rows': [
{'id': 1, 'name': 'foobar project', 'start':new Date(2010,1,23),'end':new Date(2009,1,23), 'client':'bill gates','manager': 'Steve', 'owner': '', 'category':'Marketing'},
{'id': 2, 'name': 'barfoo project', 'start':new Date(2009,1,23),'end':new Date(2009,1,23), 'client':'bill gates','manager': 'Steve', 'owner': '', 'category':'Marketing'},
{'id': 3, 'name': 'barfoo advertising', 'start':new Date(2011,1,23),'end':new Date(2009,1,23), 'client':'bill gates','manager': 'Steve', 'owner': '', 'category':'Advertising'},
{'id': 4, 'name': 'build the barfoo CMS', 'start':new Date(2012,1,23),'end':new Date(2009,1,23), 'client':'bill gates','manager': 'Steve', 'owner': '', 'category':'IT'}
]
}Concerning the Grid VS Paging VS Grouping,

my code looks like this



RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, "./fakeData/Project/list.json");
HttpProxy<Object, PagingLoadResult<ModelData>> proxy = new HttpProxy<Object, PagingLoadResult<ModelData>>(builder);

JsonReader<PagingLoadConfig> reader = new JsonReader<PagingLoadConfig>(type)
{
protected ListLoadResult newLoadResult(PagingLoadConfig loadConfig, List<ModelData> models)
{
PagingLoadResult result = new BasePagingLoadResult(models, loadConfig.getOffset(), loadConfig.getLimit());
//Window.alert(result.getData().toString());
return result;
}
};

BasePagingLoader loader = new BasePagingLoader(proxy,reader);
GroupingStore<ProjectModel> store = new GroupingStore<ProjectModel>(loader);
store.setRemoteGroup(true);
If I introduce the grouping I get an exception

com.extjs.gxt.ui.client.data.BaseGroupingLoadConfig cannot be cast to com.extjs.gxt.ui.client.data.PagingLoadConfig

which make sense to me since I am using a PagingLoadConfig to load the store ... the only problem I don't see anyway to have both feature on same grid, should I create my own class which extends both of those loaders ???

Any hints would be really appreciated, if you need me to make a full example code please let me know I get spend the half hour to make that.

Thanks you