PDA

View Full Version : Grid + JSON + pagination toolbar bug



cristianocortez
19 Jul 2010, 10:29 AM
I'm using Grid + JSON + pagination toolbar but I'm having a problem while the grid is shown with data it shows 3 rows of data but with no data written in the grid. I verified and the JSON is right.

here is part of the code :



RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://fiorino:8888/indexsearch/indexservicesearch");
HttpProxy<String> proxy = new HttpProxy<String>(builder);

// defines the json structure
ModelType type = new ModelType();
type.setTotalName("totalRows");
type.setRoot("documents");
type.addField("Titulo", "title2");
type.addField("Tipo", "type");
type.addField("Conteudo", "content");

// need a loader, proxy, and reader

JsonPagingLoadResultReader<ListLoadResult<ModelData>> reader =
new JsonPagingLoadResultReader<ListLoadResult<ModelData>>(type);

PagingLoader pagingLoader = new BasePagingLoader(proxy, reader);

pagingLoader.setRemoteSort(true);

ListStore<Document> documentListStore = new ListStore<Document>(pagingLoader);

final PagingToolBar toolBar = new PagingToolBar(5);
toolBar.bind(pagingLoader);

pagingLoader.load(0,5);would somebody tell me if it's a bug ?

Cristiano

sven
19 Jul 2010, 10:31 AM
You should also post your grid and same sample json data.

cristianocortez
19 Jul 2010, 10:38 AM
Grid :


RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://fiorino:8888/indexsearch/indexservicesearch");
HttpProxy<String> proxy = new HttpProxy<String>(builder);

// defines the json structure
ModelType type = new ModelType();
type.setTotalName("totalRows");
type.setRoot("documents");
type.addField("Titulo", "title2");
type.addField("Tipo", "type");
type.addField("Conteudo", "content");

// need a loader, proxy, and reader

JsonPagingLoadResultReader<ListLoadResult<ModelData>> reader =
new JsonPagingLoadResultReader<ListLoadResult<ModelData>>(type);

PagingLoader pagingLoader = new BasePagingLoader(proxy, reader);

pagingLoader.setRemoteSort(true);

ListStore<Document> documentListStore = new ListStore<Document>(pagingLoader);

final PagingToolBar toolBar = new PagingToolBar(5);
toolBar.bind(pagingLoader);

pagingLoader.load(0,5);

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("title");
column.setHeader("Titulo");
column.setWidth(200);
configs.add(column);

column = new ColumnConfig("type", "Tipo", 150);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);

column = new ColumnConfig("content", "Conteudo", 150);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);

ColumnModel cm = new ColumnModel(configs);

Grid<Document> grid = new Grid<Document>(documentListStore, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setAutoExpandColumn("title");
grid.setBorders(true);
grid.setStripeRows(true);

ContentPanel cp = generateDocumentContentPanel(toolBar, grid);

RootPanel.get().add(cp);


json :


{totalRows: 3, documents:[{title:"title1",type:"type1",content:"content1"},{title:"title2",type:"type2",content:"content2"},{title:"title3",type:"type3",content:"content3"}]}

Cheers,

Cristiano

sven
19 Jul 2010, 10:43 AM
type.addField("Titulo", "title2");
type.addField("Tipo", "type");
type.addField("Conteudo", "content");


That si wrong and does not much with your json and also not with your grid.

cristianocortez
19 Jul 2010, 10:48 AM
sorry it was "title" and not "title2" in the example above and anyway it doesn't show me the data in the grid !

sven
19 Jul 2010, 10:56 AM
Its still wrong.

type.addField("title");
type.addField("type");
type.addField("content");

cristianocortez
19 Jul 2010, 11:02 AM
I removed the code you suggested and still the problem persists....

now the code is :


// defines the json structure
ModelType type = new ModelType();
type.setTotalName("totalRows");
type.setRoot("documents");

sven
19 Jul 2010, 11:08 AM
I did not tell you to remove anything. I gave you the code you should try to use

cristianocortez
19 Jul 2010, 11:14 AM
That suggestion you gave me works in here !!!! Thanks and God bless you !!!!