Freeze a tree column [message #1007583] |
Wed, 06 February 2013 15:09 |
István Mészáros Messages: 51 Registered: October 2009 |
Member |
|
|
I'm trying to create a table with a freezed first column which is also a tree column. I came up with the following code based upon the NatTable examples.
My table is showing with the freezed column but the tree functionality is not visible/available.
I could use both of the features separately with no issues but no luck in combining them.
I'd appreciate any suggestions.
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, new DefaultComparator());
EventList<MProjectPortfolio> eventList = GlazedLists.eventList(portfolio);
SortedList<MProjectPortfolio> sortedList = new SortedList<MProjectPortfolio>(eventList, null);
String[] propertyNames = new String[] { ... };
IColumnPropertyAccessor<MProjectPortfolio> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<MProjectPortfolio>(propertyNames);
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ISortModel sortModel = new GlazedListsSortModel<MProjectPortfolio>(sortedList, columnPropertyAccessor, configRegistry, columnHeaderDataLayer);
final TreeList<MProjectPortfolio> treeList = new TreeList<MProjectPortfolio>(sortedList, new MProjectPortfolioTreeFormat(sortModel), new MProjectPortfolioExpansionModel());
GlazedListTreeData<MProjectPortfolio> treeData = new MProjectPortfolioTreeData(treeList);
GlazedListsDataProvider<MProjectPortfolio> bodyDataProvider = new GlazedListsDataProvider<MProjectPortfolio>(treeList, columnPropertyAccessor);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer, new GlazedListTreeRowModel<MProjectPortfolio>(treeData), false);
FreezeLayer freezeLayer = new FreezeLayer(treeLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, compositeFreezeLayer, selectionLayer);
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
SortHeaderLayer<MProjectPortfolio> sortHeaderLayer = new SortHeaderLayer<MProjectPortfolio>(columnHeaderLayer, sortModel, false);
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, compositeFreezeLayer, selectionLayer);
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sortHeaderLayer);
GridLayer gridLayer = new GridLayer(compositeFreezeLayer, sortHeaderLayer, rowHeaderLayer, cornerLayer);
NatTable natTable = new NatTable(container, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new DefaultTreeLayerConfiguration(treeLayer));
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.configure();
selectionLayer.setSelectedCell(1, 0);
natTable.doCommand(new FreezeSelectionCommand());
selectionLayer.clear();
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.17524 seconds