Ext GWT 2.5 Paging grid using rpc
I am trying to use a Ext-gwt paged grid .but the grid is displaying empty
data. i am using Gwt-Rpc. I can see the lines in the grid,but the objects
are empty.
ServiceImplementation:`
public PagingLoadResult<DemandeDTO> findallpaging(PagingLoadConfig config){
ArrayList<DemandeDTO> demandeList = DemandeDAO.findall();
int offset = config.getOffset();
int limit = demandeList.size();
if (config.getLimit() > 0) {
limit = Math.min(offset + config.getLimit(), limit);
}
ArrayList<DemandeDTO> sublist = new ArrayList<DemandeDTO>();
for(int i=offset; i < limit; ++i) {
sublist.add(demandeList.get(i));
}
BasePagingLoadResult<DemandeDTO> result = new
BasePagingLoadResult<DemandeDTO>
(sublist,offset,demandeList.size());
return(result);
}
The client:
RpcProxy<PagingLoadResult<DemandeDTO>> proxy = new
RpcProxy<PagingLoadResult<DemandeDTO>>() {
@Override
public void load(Object loadConfig,
AsyncCallback<PagingLoadResult<DemandeDTO>> callback) {
demandeService.findallpaging((PagingLoadConfig) loadConfig,
callback);
}
};
// loader
final PagingLoader<PagingLoadResult<ModelData>> loader = new
BasePagingLoader<PagingLoadResult<ModelData>>(
proxy);
loader.setRemoteSort(true);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final PagingToolBar toolBar = new PagingToolBar(50);
toolBar.bind(loader);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("demandeId", "Numero", 60);
config.add(column);
column = new ColumnConfig("dateDemande", "Date", 150);
config.add(column);
column = new ColumnConfig("demandeur", "Demandeur",200);
config.add(column);
column = new ColumnConfig("typeDemande", "Type", 100);
config.add(column);
column = new ColumnConfig("sujetDemande", "Sujet", 200);
config.add(column);
column = new ColumnConfig("detaillDemande", "Detaille", 220);
config.add(column);
column = new ColumnConfig("prioriteDemande", "Priorite", 100);
config.add(column);
column = new ColumnConfig("service", "Service", 100);
config.add(column);
final ColumnModel cm = new ColumnModel(config);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
grid.setStateful(true);
grid.addListener(Events.Attach, new
Listener<GridEvent<ModelData>>() {
public void handleEvent(GridEvent<ModelData> be) {
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(50);
Map<String, Object> state = grid.getState();
if (state.containsKey("offset")) {
int offset = (Integer)state.get("offset");
int limit = (Integer)state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
loader.load(config);
}
});
grid.setLoadMask(true);
grid.setBorders(true);
final ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setVisible(false);
panel.setHeading("Demandes");
panel.setSize(1140, 433);
panel.setLayout(new FitLayout());
panel.add(grid);
Thank you in advance.
No comments:
Post a Comment