0

Change the background of the TreeRow

asked 2014-03-19 11:13:09 +0800

Amol987 gravatar image Amol987
15 3

Hi, I have customized standard zk tree component by extending Tree class and defining the Model and the renderer class. So i m generating three level Tree.

  • product
    • Module
      • Jars

What i want is ,even row should have different background than odd ones. i don't want to change the style from the zul file. style should be applied on creation of tree only. Thanks in advance.

delete flag offensive retag edit

Comments

Hey @chillworld thanks for your answer, your solution is logically correct , but it isn't working .can you please check the issue. (else than .colorEven{ background:Blue}; should be .colorEven{ background:Blue;} ) if needed should i provide you the code.?

Amol987 ( 2014-03-19 12:11:32 +0800 )edit

does it work when you change the ; from place? I didn't tested it out cause it was pretty simpel, of course then there could be typmistakes coming up :) (IngoB solution you can try also, with that you don't need to set the style tag)

chillworld ( 2014-03-19 14:10:33 +0800 )edit

No it doesn't works with the change also, so i m expecting the reason of not working. and the IngoB sol. works fine :)

Amol987 ( 2014-03-19 14:41:55 +0800 )edit

oke updated to ingoB his solution and upvoted ingoB's answer ;)

chillworld ( 2014-03-19 14:53:42 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
1
link publish delete flag offensive edit

Comments

also possible ;)

chillworld ( 2014-03-19 14:08:20 +0800 )edit
0

answered 2014-03-19 11:31:35 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2014-03-19 14:53:02 +0800

In your renderer you have this :

public void render(Treeitem treeitem, Object data, int index) throws Exception {
}

put this in your renderer, so just see if index is even or not like this :

if (index%2==0) {
    treeitem.setStyle("background:red");
} else {
    treeitem.setStyle("background:blue");
}

Greetz chill.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-03-19 11:13:09 +0800

Seen: 14 times

Last updated: Mar 19 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More