PagedTable
A Table component that uses pages instead of scrolling
NOTE: 0.6.3 is for Vaadin 6 0.6.5 is for Vaadin 7 0.7.0 is for Vaadin 8 in compatibility mode
Download the version depending on which version of Vaadin you are using!!
0.7.0 Is for compatibility mode, for migrating from Vaadin 7 to Vaadin 8 projects. When you have migrated, I suggest you switch from Table to Grid. GridExtensionPack Add-on provides a Paged Container and that does similar things to Grid as this addon does to Table.
PagedTable
PagedTable is a component that behaves in the same matter as the Vaadin core Table, except that it has multiple pages instead of scrolling to show more entries.
You can set the amount of rows to be shown with setPageLength. Changing pages can be implemented yourself with the methods nextPage(), previousPage(), getCurrentPage(), getTotalAmountOfPages() or you can ask the table to create a control layout for you with createControls (returns a HorizontalLayout).
The table has a handler, PageTableEvents, that can be set with setHandler. The handler will notify you when viewed page has changed
Known issues:
- setHeight causes wrong amout of rows to be rendered and renders one (half) row too much. This will cause a very little scrollable scrollbar to the table. Use setPageLength instead if possible.
- Having different height rows will throw off the rendering. Same symptoms as above.
Further Improvements to be made:
- Figure out how the component reacts with live changes to the real container after the original rendering.
The component is still work in progress and I'm actively working on making it better. If you test it out, please, show your interest and post your feedback to the forum thread in "related links" so that I can get around and fix it. More discussion about the component can be found in the same thread. Don't forget to vote!
Sample code
public class TabletestApplication extends Application { @Override public void init() { VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeUndefined(); Window mainWindow = new Window("Tabletest Application"); IndexedContainer container = new IndexedContainer(); container.addContainerProperty("foo", String.class, null); container.addContainerProperty("bar", String.class, null); container.addContainerProperty("baz", String.class, null); for (int i = 0; i < 100; i++) { Item item = container.addItem(i); item.getItemProperty("foo").setValue("foo " + i); item.getItemProperty("bar").setValue("bar"); item.getItemProperty("baz").setValue("baz"); } PagedTable table = new PagedTable("footable"); table.setContainerDataSource(container); table.setPageLength(15); mainWindow.addComponent(table); mainWindow.addComponent(table.createControls()); setMainWindow(mainWindow); } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
This is the Vaadin 8 PagedTable in compatibility mode, for migrating from Vaadin 7 to Vaadin 8 projects. When you have migrated, I suggest you switch from Table to Grid. GridExtensionPack Add-on provides a Paged Container and that does similar things to Grid as this addon does to Table.
Thanks to Johannes for motivation :)
- Released
- 2017-04-01
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 8.0+
- Vaadin 6.4+ in 0.1.0
- Vaadin 6.2+ in 0.2.0
- Vaadin 6.0+ in 0.5.0
- Vaadin 7.0+ in 0.6.4
- Browser
- Browser Independent
PagedTable - Vaadin Add-on Directory
A Table component that uses pages instead of scrollingOnline Demo
Discussion Forum
Issue Tracker
Source Code
PagedTable version 0.1.0
Initial release.
PagedTable version 0.2.0
The component architecture is redone. The PagedTable now extends Table instead of PagedTable. This is a much cleaner solutioon but it means that it can't give you the controls directly. You can instead call myLayout.addComponent(table.createControls()) to get the standard control bar.
Features:
- Extends Table instead of CustomComponent
- Methods to get current and total page counts
- Methods to call next and previous page from the code.
- Get the standard controls with createControls()
- Give the user control to implement the next and previous button himself.
PagedTable version 0.3.0
New in version 0.3.0
- Changed handler to listners so that multiple items can listen to paged table events
- Changed the listener event to contain a PagedTableChangeEvent object with all data in it instead of providing separate primitives. This is more in line with the genreral way events are handled in Vaadin.
- Added a setCurrentPage(int) method for page jumping
- remade the default controls to contain page jumping and page size selector
- added style names to all components for theming
- implemented column sorting.
Big thanks goes to Kevin Ferrare for providing valuable feedback and improvements on the previous version.
PagedTable version 0.4.0
- Performance boost: generatedCells were called even thousands on times on page change. Now it is called only once per row so total call amount is the same as page length.
- Performance boost: Tables refreshRenderCells was called over a hundred times on page change and because of that all cells were rendered way too many times. Now it is called only 12 times.
- Bug fix: made the getCurrentPage() and getTotalAmountOfPages() to return value 1 when the container is empty. It caused some funky "page 1 of 0" states and it now shows "page 1 of 1" that is more logical
reordered the code in the default control bar so that it doesn't cause a page change event.
The issues reported have been fixed and as I've haven't got any new ones in a while. The component seems thus to work and I'm promoting it from it's Experimental stage to Beta stage.
PagedTable version 0.4.1
While making big performance boosts in 0.4.0, I accidentally introduced a bug which "nullified" some table features upon page change, like sorting and custom column headers. This problem is now fixed.
As a little extra bonus, this fix added a little more performance boost to the last fix. Version 0.4.0 dropped the calls on Table.refreshRenderedCells() from about a hundred per page change to six. This fix dropped it down to one. Seems like changing a container in a core Vaadin table calls refresh six times. Instead I disabled automatic item set change notifications from the container and fired one manually after the container item changes was done based on a page change.
PagedTable version 0.5.0
Added the feature to have the column sizes resized automatically on page change depending on the data in the table. Use table.setAlwaysRecalculateColumnWidths(true); to turn the feature on.
From now on I will have the version number of PagedTable in the file name so that you have a easier way to find out which version you are using. Remember to delete the old version
PagedTable version 0.5.1
Bugfix.
Some container return a id for container.getNextItemId(itemId) even when there is no next id, for example "return ++currentId;" Added a check that actually fetches the item before deciding if it should add it to the view or not.
PagedTable version 0.6.0
Changed the container implementation which is used behind the scenes to a totally new approach. New implementation should be a lot more robust and should not interfere with existing Table features.
Nearing 1.0..
PagedTable version 0.6.1
Proxy container now implements Container instead of extending AbstractContainer to make it compatible with Vaadin versions pre 6.6
PagedTable version 0.6.2
Three delegate methods did not delegate the data correctly, and the caused instead a infinite loop. These were fixed.
PagedTable version 0.6.3
PagedChangedListener is now public. Having default visiblilty on the interface caused problems in some environments.
PagedTable version 0.6.4
This release is form making the add-on Vaadin 7 compatible. This version will only work with Vaadin 7. Download 0.6.3 if you are using Vaadin 6!
PagedTable version 0.6.5
A big thank you to Roman Romanchuk for version 0.6.5. He pulled version 0.6.4 and updated it from Vaadin 7 alpha to Vaadin 7 beta, and then did a pull request of it back to me. The add-on is now compatible with the Vaadin 7 beta 7 and will most likely be compatible with Vaadin 7 final.
PagedTable version 0.7.0
This is the Vaadin 8 PagedTable in compatibility mode, for migrating from Vaadin 7 to Vaadin 8 projects. When you have migrated, I suggest you switch from Table to Grid. [GridExtensionPack Add-on](https://vaadin.com/directory#!addon/gridextensionpack-add-on) provides a Paged Container and that does similar things to Grid as this addon does to Table.
Thanks to Johannes for motivation :)