Edit: online demo added. See link near the end
Up to now, there was no real need for me to use a treetable in my apps. Therefore there has been little interest from me in the PrimeFaces treetable that provides this functionality. So when the need arose, I had a look and it honestly provided way to little functionality for what I need: The treetable is much closer to a tree than the datatable. The fact that more people would like to have a treetable that more closly resembles a datatable is reflected by the issues reported…
Have the datatable support tree like functionality
This is the treeDataTable in a full page layout where the header is in the ‘north’ layout-section and the treeDataTable occupies 100% of the width AND height of the center section. You can even see the ‘background’ of the datatable filled with empty non-selectable rows if the number of records is lower than the avaliable visible row space. And yes there still needs to be some work done on the odd-even row coloring when collapsing rows (fully expanded it is ok). (fixed, just not updated the image)
And here you see the tree functionality at work and a scrollbar appearing AND the colum headers fitting perfectly.
Expanding is currently done client-side, has no event and the implementation still requires to have the full tree for this page available. But this is not different than with the current TreeTable and for me this is sufficient.
The empty message works to…
Showing it is not ‘optimal’ imo and I probably want to display it in the middle of the datatable as an overlay, but that would mean using less of the existing datatable, but maybe some jquery might come to the rescue here.
Filtering works in the way it is done in the current datatable.
In this example you only see that only top level records that match the filter are shown, but if you want this to be different, just implement it differently in your load method in the TreeTableDataModel (This extends the LazyDataTableModel with one method to get to the children of a node). You could e.g. choose to show matched records and it’s children, or even go ‘up the tree’ to find the ancestor of a matched record that is a top level record. It is totally up to you.
Ofcourse sorting works as well (even multi sorting)
In addition to all of the above, it also does (personally tested)
- Draggable columns
- Resizable columns
- Dynamic columns
- Conditional coloring
- Row editing
- Single/multiple selection (row and/or checkbox/radiobutton based)
- Headers, footers
- Context Menu
What is not tested yet (simply because I do not need it) is:
- Grouping
- SubTable
- Summary Row
- Expandable Rows
- Cell Editing
- Lazy Loading
But an online demo is available…
Great work Ronald! I for one would be very happy with this addition. Especially the 100% height which I never understood why this was not implemented in the Datatable.
When it’s released we will have a beer to celebrate 🙂
online demo available.
Interesting blog, Ronald. thanks for sharing!!!
Any news on the release date? Very nice initiative by the way man! Thx very much!
Wel, have to catch up with some good changes in the original datatable, so it will take a few days..