PDA

View Full Version : GXT Json Pagination Issues



sverma
25 Oct 2009, 11:17 PM
Hi,

These seems to be a problem with GXT Json Pagination using JsonPagingLoadResultReader, BasePagingLoader, PagingToolBar, ListStore.

The sample code is depicted below.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client;

import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.HttpProxy;
import com.extjs.gxt.ui.client.data.JsonPagingLoadResultReader;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.ui.RootPanel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* Main entry point.
*
* @author versh03
*/
public class MainEntryPoint implements EntryPoint {
/**
* Creates a new instance of MainEntryPoint
*/
public MainEntryPoint() {
}

/**
* The entry point method, called automatically by loading a module
* that declares an implementing class as an entry-point
*/
public void onModuleLoad() {
RequestBuilder builder=new RequestBuilder(RequestBuilder.GET,GWT.getHostPageBaseURL()+"oslist.json");
HttpProxy proxy=new HttpProxy(builder);
ModelType type=new ModelType();
type.setRoot("os_records");
type.addField("Name", "name");
type.addField("Type", "type");
type.addField("OperatingSystem", "operatingSystem");
List<ColumnConfig> columnConfigs=new ArrayList<ColumnConfig>();
columnConfigs.add(new ColumnConfig("Name", "Name", 150));
columnConfigs.add(new ColumnConfig("Type", "Type", 150));
columnConfigs.add(new ColumnConfig("OperatingSystem", "OperatingSystem", 150));
JsonPagingLoadResultReader reader=new JsonPagingLoadResultReader(type);
final BasePagingLoader loader=new BasePagingLoader(proxy, reader);
PagingToolBar pagingToolBar=new PagingToolBar(2);
pagingToolBar.bind(loader);
loader.load(0,2);
ContentPanel panel=new ContentPanel();
panel.setTitle("Json Paging Demo");
ListStore store=new ListStore(loader);
ColumnModel model=new ColumnModel(columnConfigs);
final Grid grid=new Grid(store, model);
grid.setAutoWidth(true);
grid.setAutoHeight(true);
grid.setBorders(true);
grid.setStateful(true);
panel.add(grid);
panel.add(pagingToolBar);
RootPanel.get().add(panel);

}
}


The oslist.json sample json content is displayed below.

{
os_records:[
{
name:"Win XP",
type:"WXPP",
operatingSystem:"Windows XP Professional XP2"
},
{
name:"Win 2000",
type:"W2K",
operatingSystem:"Windiws 2000 Edition"
},
{
name:"Linux RH",
type:"RHL",
operatingSystem:"Red Hat Enterprise Linux"
},
{
name:"Ubuntu",
type:"Ubuntu",
operatingSystem:"Ubuntu Operating System"
},
{
name:"SunSolaris",
type:"SSOL",
operatingSystem:"Sun Solaris Enterprise"
},
{
name:"Fedora Core",
type:"Fedora",
operatingSystem:"Fedora Core Linux"
},
{
name:"Mandrake Linux",
type:"Mandrake",
operatingSystem:"Mandrake Linkux Operating System 10.1"
},
{
name:"Windows7",
type:"Windows7",
operatingSystem:"Windows7 Operating System"
},
{
name:"Macintosh",
type:"MAC",
operatingSystem:"Macintosh Operating System"
},
{
name:"HP-UX",
type:"UNIX",
operatingSystem:"HP Unix Operating System"
}
]
}

However, we are not able to produce proper pagination using this JSON scheme of GXT. The problem we are facing are
1) There is no on demand loading. All the contents are displayed in the first call itself even though pagsize is 2.
2) The paging tool bar's next button is not generating proper offset and limit.

Any help would be appreciated regarding proper implementation of Dynamic Json pagination using GXT.

Thanks.

sven
26 Oct 2009, 2:15 AM
The was a small issue that got aloready fixed with GXT 2.0.2.

Most part of the questions is however better placed in the help forum. I amm oving the post to the correct place.

sverma
26 Oct 2009, 4:01 AM
The was a small issue that got aloready fixed with GXT 2.0.2.

Most part of the questions is however better placed in the help forum. I amm oving the post to the correct place.


Hi, I have developers licence for GXT 2.0.1. Can I download GXT 2.0.2 for using with the same licence?

sven
26 Oct 2009, 4:14 AM
2.0.2 is a support release, you need a support subscription for this.

The main problem is that your httpproxy always returns all the results and not only the one that were requested. When a pagesize is 2, than you can only return 2 results.