Vaadin-grid: Feature: Removing HeaderRow from the Grid

Created on 17 Jan 2019  路  12Comments  路  Source: vaadin/vaadin-grid

There is a feature of adding a HeaderRow to the Grid, but there seems not to be any server-side API for removing one.

It would be nice if this feature would be also available.

Thanks!

components enhancement flow

Most helpful comment

It seems that vaadin/vaadin-grid-flow#477 would not quite meet the requirements here.

Would something like

HeaderRow header = grid.prependHeaderRow();
// something happens
header.remove();

match these requirements?

All 12 comments

Wondering if this is related to / dupe of https://github.com/vaadin/vaadin-grid-flow/issues/477?

@anasmi Is there a use-case that would require this feature, or would a fix for vaadin/vaadin-grid-flow#477 be enough?

If vaadin/vaadin-grid-flow#477 also allows to remove any custom added HeaderRow- then yes, but based on description it has something to do with setHeader and doesn't address this feature. (Please, correct me, if I am wrong)

For example from the first code snippet here : https://vaadin.com/components/vaadin-grid/java-examples/header-and-footer-rows
I would like to have an option to remove topRow

It seems that vaadin/vaadin-grid-flow#477 would not quite meet the requirements here.

Would something like

HeaderRow header = grid.prependHeaderRow();
// something happens
header.remove();

match these requirements?

Yes! this indeed would be nice :)

HeaderRow header = grid.prependHeaderRow();
// something happens
header.remove();

still on the road?

One particular reason where this is desirable is to automatically create columns based on bean properties, but not show the headers. Today, it seems like this is not possible, so you have to choose between automatic creation and not showing any header.

What happens is basically that addColumn("propertyName") causes the "default" header row to be created if it doesn't already exist. After that has happened, it's apparently no longer possible to remove that header row.

A really ugly workaround that may or may not work in real-world cases:

grid.getElement().getNode().runWhenAttached(ui -> ui.beforeClientResponse(this, context -> {
    grid.getElement().getChildren().filter(element -> "vaadin-grid-column".equals(element.getTag()))
            .flatMap(Element::getChildren)
            .filter(element -> "template".equals(element.getTag()) && element.getClassList().contains("header"))
            .forEach(Element::removeFromParent);
}));

Any updates?

I have the same problem with the footer row. I can add a new footer row but I can not delete the footer if it is not necessary any more.

Same here, we are currently migrating from Vaadin 7 to Vaadin 18 and the feature to remove footer rows is missing.

Is there something new on this topic? These feature is critical for dynamic filters.

Was this page helpful?
0 / 5 - 0 ratings