Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Set styling on specific tree item

Max Hellstrand
10 years ago Mar 20, 2012 9:13am
Jouni Koivuviita
10 years ago Mar 20, 2012 9:37am
Max Hellstrand
10 years ago Mar 20, 2012 10:22am
Max Hellstrand
10 years ago Mar 20, 2012 12:11pm
Charles Anthony
10 years ago Mar 20, 2012 12:46pm

Hi Max,

I would have thought (I've not used the Tree at all, let alone the ItemStyleGenerator ) that ItemStyleGenerator is set once, and called for every item when it is rendered.

So, I *think* that you would want to do something more like this (typed in browser, not tested or even compiled!):

customerTree.setItemStyleGenerator(new Tree.ItemStyleGenerator(){
   @Override
    public String getStyle(Object itemId) {
      Item item = customerTree.getItem(itemId);
      String itemName = item.getItemProperty("name").getValue().toString().toLowerCase();
      if(itemName.equals(filter))    {
        return "bold";
      } else {
        return "";
      }
    }
}});

I'm not sure how to get the tree to refresh the style when filter changes - probably force a repaint somehow.

HTH,

Cheers,

Charles.

Last updated on Mar, 20th 2012
Jouni Koivuviita
10 years ago Mar 20, 2012 1:58pm
Max Hellstrand
10 years ago Mar 20, 2012 2:16pm
Max Hellstrand
10 years ago Mar 20, 2012 2:49pm
Bernhard Steinheber
8 years ago Jul 30, 2013 3:13pm
Palanivel Muthugounder
7 years ago Oct 28, 2014 10:48am