Grid table... table.setHeightMode(HeightMode.ROW); table.setDetailsGenerator(new DetailsGenerator() { public Component getDetails(RowReference rowReference) { table.setHeightByRows(tableContainer.getItemIds().size() + 4); //detalis height is constant so I solve this by adding extra space which equals the size of 4 the rows // //for filtered container you can use tableContainer.getVisibleItemIds() } }
@Override protected void doReadDesign(Element design, DesignContext context) { Attributes attrs = design.attributes(); if (design.hasAttr(DECLARATIVE_DATA_ITEM_TYPE)) { String itemType = design.attr(DECLARATIVE_DATA_ITEM_TYPE); setBeanType(itemType); } if (attrs.hasKey("selection-mode")) { setSelectionMode(DesignAttributeHandler.readAttribute( "selection-mode", attrs, SelectionMode.class)); } Attributes attr = design.attributes(); if (attr.hasKey("selection-allowed")) { setReadOnly(DesignAttributeHandler .readAttribute("selection-allowed", attr, Boolean.class)); } if (attrs.hasKey("rows")) { setHeightByRows(DesignAttributeHandler.readAttribute("rows", attrs, double.class)); } readStructure(design, context); // Read frozen columns after columns are read. if (attrs.hasKey("frozen-columns")) { setFrozenColumnCount(DesignAttributeHandler .readAttribute("frozen-columns", attrs, int.class)); } }
/** * Sets the number of rows that should be visible in internal Grid's body. * @param rows the number of rows to set */ public void setHeightByRows(double rows) { getGrid().setHeightByRows(rows); }
@Override public B heightByRows(double rows) { getInstance().getGrid().setHeightMode(HeightMode.ROW); getInstance().getGrid().setHeightByRows(rows); return builder(); }
private Grid<Cache> createCacheGrid(CacheManager cacheManager) { Grid<Cache> grid = new Grid<>(); grid.addColumn(Cache::getName).setCaption("Name"); grid.addColumn(cache -> ((Double) (((double) cache.getStatistics().cacheHitCount()) / ((double) (cache.getStatistics().cacheMissCount() + cache.getStatistics().cacheHitCount())) * 100)).intValue() + "%").setCaption("Hit Ratio"); grid.addColumn(cache -> cache.getCacheConfiguration().getMaxEntriesLocalHeap()).setCaption("Max Size"); grid.addColumn(Cache::getSize).setCaption("Size"); grid.addColumn(Cache::getStatus).setCaption("Status"); grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToIdleSeconds()).setCaption("TTldle(s)"); grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToLiveSeconds()).setCaption("TTLive(s)"); grid.addColumn(cache -> cache.getStatistics().cacheHitCount()).setCaption("hit"); grid.addColumn(cache -> cache.getStatistics().cacheMissExpiredCount()).setCaption("miss : Expire"); grid.addColumn(cache -> cache.getStatistics().cacheMissNotFoundCount()).setCaption("miss : Not Found"); grid.setItems(Arrays.stream(cacheManager.getCacheNames()) .map(cacheManager::getCache) .collect(Collectors.toList())); grid.setSizeFull(); grid.setSelectionMode(Grid.SelectionMode.NONE); int cacheSize = cacheManager.getCacheNames().length; if (cacheSize != 0) { grid.setHeightByRows(cacheSize > 10 ? 10 : cacheSize); } return grid; } }
private Grid<Cache> createCacheInfoGrid() { Grid<Cache> grid = new Grid<>(); grid.addColumn(Cache::getName).setCaption("Name"); grid.addColumn(cache -> ((Double) (((double) cache.getStatistics().cacheHitCount()) / ((double) (cache.getStatistics().cacheMissCount() + cache.getStatistics().cacheHitCount())) * 100)).intValue() + "%").setCaption("Hit Ratio"); grid.addColumn(cache -> cache.getCacheConfiguration().getMaxEntriesLocalHeap()).setCaption("Max Size"); grid.addColumn(Cache::getSize).setCaption("Size"); grid.addColumn(Cache::getStatus).setCaption("Status"); grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToIdleSeconds()).setCaption("TTldle(s)"); grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToLiveSeconds()).setCaption("TTLive(s)"); grid.addColumn(cache -> cache.getStatistics().cacheHitCount()).setCaption("hit"); grid.addColumn(cache -> cache.getStatistics().cacheMissExpiredCount()).setCaption("miss : Expire"); grid.addColumn(cache -> cache.getStatistics().cacheMissNotFoundCount()).setCaption("miss : Not Found"); grid.setItems(Collections.singletonList(this.ehcache)); grid.setWidth("100%"); grid.setSelectionMode(Grid.SelectionMode.NONE); grid.setHeightByRows(1); return grid; }
int ehcacheSize = this.ehcache.getKeys().size(); if (ehcacheSize != 0) { grid.setHeightByRows(ehcacheSize > 15 ? 15 : ehcacheSize);