java - Implement SimplePager with DataGrid and AsyncDataProvider -
how implement simplepager asyncdataprovider when data grid provided values fectched server.
you have create class extending asyncdataprovider
. in class can override onrangechanged
-method.
my class example looks this:
public class asynclistprovidervisit extends asyncdataprovider<myobject> { @override protected void onrangechanged(hasdata<myobject> display) { // new range. final range range = display.getvisiblerange(); /* * query data asynchronously. if using database, can * make rpc call here. we'll use timer simulate delay. */ final int start = range.getstart(); int length = range.getlength(); service.util.getinstance().getpartofimmoobjects(start, length, new asynccallback<list<myobject>>() { @override public void onfailure(throwable caught) { confirmationpanel cp = new confirmationpanel(); cp.confirm("error!", "an error occurred during data-loading."); } @override public void onsuccess(list<myobject> result) { if (result != null) { updaterowdata(start, result); } } }); } }
then need create datagrid, asyncprovider , pager, this:
// create celllist. datagrid<lcvisits> grid = new datagrid<lcvisits>(); // create data provider. asynclistprovidervisit dataprovider = new asynclistprovidervisit(); // add celllist dataprovider. dataprovider.adddatadisplay(grid); // create paging controls. simplepager pager = new simplepager(); pager.setdisplay(grid); // , add them panel, container, whatever container.add(grid); container.add(pager);
edit
as andre pointed out in comment need fetch correct row-count query. did "fake-object", add list , delete on client side. can call updaterowcount(rowcount, isexact)
isexcact
boolean
indicating whether row-count entered exact count or estimated.
Comments
Post a Comment