How can I set style on a specific column on every row?

I am using Vaadin 14.
I am able to apply style when I am creating a Column

Column<Person> nameColumn = personGrid.addColumn(new ComponentRenderer<>(person -> {
        Label nameFieldLabel = new Label(person.getName());
        nameFieldLabel.getStyle().set("color", "red");
        return nameFieldLabel;
    }
}))
    .setKey("name")
    ....

But now I want the behavior:

if user click on a certain button, I want to iterate all the rows to get the nameFieldLabel, so that I can remove the blue color style on it
doing something like:

label.getStyle().remove("color");

How can I do that?

So many things… let’s make it short

  • over-usage of component columns is a performance problem
  • using Label for such things is a accessibility nightmare
  • there is setClassNameGenerator on the grid to style rows based on your criteria with css
  • if you need to recalculate those styles: refresh your items / provider

What would you suggest me to use if not Label?
I want it to look like a hyper link so that user knows that they can click on it to open up a dialog.

You should use a button for that.

So I need to display some text for the users.
I switch to using Span instead.

If you need to display a text without any action ( like open a dialog) then a Span is a good fit

Thanks.
Is there a way to iterate the rows and to get to a specific column?
So I have a column that is a span and it has hyper link style applied, and when user click a button, I want to disable to hyper link style for that column on all rows.

I’m not sure if the grid is the best component or what you’re trying to build. In your specific case, I would probably update a CSS variable to update everything.

Or use refreshAll and re-render everything.