Hi, someone can post a complete example of use of Data presentation Widget? it'll be also welcome an example of server side.
Thanks Best regards On 3 Giu, 14:14, Paul Stockley <pstockl...@gmail.com> wrote: > Sorry my message got truncated: > > Your over complicating it. You should just subclass > AsyncListViewAdapter such as: > > protected class residentAsyncAdapter extends > AsyncListViewAdapter<ResidentListDO>{ > @Override > protected void onRangeChanged(ListView<ResidentListDO> view) { > Range newRange = view.getRange(); > > updateViewData(newRange.getStart(), > newRange.getLength(), <a list > ofdatafor the requested range>); > } > } > > Then add the table as a view of the adapter > > CellTable<ResidentListDO> residentTable = new > CellTable<ResidentListDO>(5); > > Column<ResidentListDO, String> unitColumn = new > Column<ResidentListDO, String>(new TextCell()) { > @Override > public String getValue(ResidentListDO object) { > return object.getUnit(); > } > > }; > > residentTable.addColumn(unitColumn, "Unit"); > > SimplePager<ResidentListDO> thePager = new > SimplePager<ResidentListDO>(residentTable); > residentTable.setPager(thePager); > > mainGridContainer.add(residentTable); > pagerContainer.add(thePager); > > residentAsyncAdapter residentTableAdapter = new > residentAsyncAdapter(); > residentTableAdapter.addView(view.residentTable); > residentTableAdapter.updateDataSize(<size ofdataset>, true); > > If you have a list on the client already for thedataset it is even > easier. Instead of using > AsyncListViewAdapter use ListViewAdapter as follows: > > List<ResidentListDO> ourList = new ArrayList<ResidentListDO>(); > ListViewAdapter<ResidentListDO> residentTableAdapter = new > ListViewAdapter<ResidentListDO>(ourList ); > residentTableAdapter.addView(view.residentTable); > //No need to call updateDataSize > > On Jun 3, 7:52 am, Paul Stockley <pstockl...@gmail.com> wrote: > > > Your making it overly complicated: > > > For the case where you have all thedatain a list already: > > > Column<ResidentListDO, String> unitColumn = new > > Column<ResidentListDO, String>(new TextCell()) { > > @Override > > public String getValue(ResidentListDO object) { > > return object.getUnit(); > > } > > }; > > > Column<ResidentListDO, String> nameColumn = new > > Column<ResidentListDO, String>(new TextCell()) { > > @Override > > public String getValue(ResidentListDO object) { > > return object.getName(); > > } > > }; > > > residentTable.addColumn(unitColumn, "Unit"); > > residentTable.addColumn(nameColumn, "Name"); > > > SimplePager<ResidentListDO> thePager = new > > SimplePager<ResidentListDO>(residentTable); > > residentTable.setPager(thePager); > > > mainGridContainer.add(residentTable); > > pagerContainer.add(thePager); > > > residentTableAdapter = new residentAsyncAdapter(); > > > On Jun 2, 11:18 pm, Andrew <yenchu.chen...@gmail.com> wrote: > > > > The following code is what I'm woking on, hope it can help you: > > > > protected void init() { > > > VerticalPanel container = new VerticalPanel(); > > > initWidget(container); > > > > int pageSize = 10; > > > CellTable<User> cellTable = new CellTable<User>(pageSize); > > > setColumns(cellTable); > > > setSelectionModel(cellTable); > > > > setDataSize(cellTable); > > > int pageStart = 0; > > > loadData(pageStart, pageSize, cellTable); > > > > SimplePager<User> pager = createPager(cellTable); > > > > container.add(cellTable); > > > container.add(pager); > > > } > > > > private SimplePager<User> createPager(final CellTable<User> > > > cellTable) { > > > SimplePager<User> pager = new SimplePager<User>(cellTable, > > > SimplePager.TextLocation.CENTER) { > > > public void > > > onRangeOrSizeChanged(PagingListView<User> listView) { > > > loadData(listView.getPageStart(), > > > listView.getPageSize(), > > > listView); > > > super.onRangeOrSizeChanged(listView); > > > } > > > }; > > > return pager; > > > } > > > > private void setColumns(CellTable<User> cellTable) { > > > cellTable.addColumn(new TextColumn<User>() { > > > @Override > > > public String getValue(User user) { > > > return user.getName(); > > > } > > > }, new TextHeader("Name")); > > > > cellTable.addColumn(new TextColumn<User>() { > > > @Override > > > public String getValue(User user) { > > > return user.getLocation(); > > > } > > > }, new TextHeader("Location")); > > > } > > > > private void setSelectionModel(CellTable<User> cellTable) { > > > final SingleSelectionModel<User> selectionModel = new > > > SingleSelectionModel<User>(); > > > SelectionChangeHandler selectionHandler = new > > > SelectionChangeHandler() { > > > @Override > > > public void > > > onSelectionChange(SelectionChangeEvent event) { > > > User user = > > > selectionModel.getSelectedObject(); > > > Window.alert(user.getId() + ": " + > > > user.getName()); > > > } > > > }; > > > > > > selectionModel.addSelectionChangeHandler(selectionHandler); > > > cellTable.setSelectionEnabled(true); > > > cellTable.setSelectionModel(selectionModel); > > > } > > > > private void setDataSize(final PagingListView<User> cellTable) { > > > employeeRequest.countUsers(new AsyncCallback<Integer>() { > > > public void onFailure(Throwable caught) { > > > Window.alert("Request failure: " + > > > caught.getMessage()); > > > } > > > > public void onSuccess(Integer result) { > > > cellTable.setDataSize(result, true); > > > } > > > }); > > > } > > > > private void loadData(int start, int size, > > > final PagingListView<User> cellTable) { > > > employeeRequest.getUsers(start, size, > > > new AsyncCallback<PagingData<User>>() { > > > public void onFailure(Throwable > > > caught) { > > > Window.alert("Request > > > failure: " + caught.getMessage()); > > > } > > > > public void > > > onSuccess(PagingData<User> result) { > > > > > > cellTable.setData(result.getStart(), > > > > > > result.getLength(), result.getValues()); > > > } > > > }); > > > } -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.