0

Unable to set MenuItem label style through java class

asked 2016-09-05 05:47:10 +0800

nirmalmandhata gravatar image nirmalmandhata flag of India
2 3

We need to set the style property of MenuItem label through java class. For the we are taking the MenuItem object through its id and setting the style to the menuitem through .setStyle method of MenuItem. But its not able to set style to the MenuItem label because style is set to li tag rather than span tag. Component component = view.getFellowIfAny(fieldId); MenuItem menuItem = (MenuItem) component; if (menuItem != null) { menuItem.setStyle(style); }

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-09-06 01:22:37 +0800

MDuchemin gravatar image MDuchemin
1346 1 4
ZK Team

Hi nirmalmandhata, Welcome to ZK forum.

You can add custom classes to your components through sclass: https://www.zkoss.org/wiki/ZK%20Style%20Customization%20Guide/ZK%20CSS%20Class%20Design/Sclass

From there, just open your developer tools and look at the DOM tree:

myComponent.setSclass("myCustomCssClass");

will roughly render as:

<li id="xyz" class="z-menuitem myCustomCssClass">
 <a href="javascript:;" id="zyz-a" class="z-menuitem-content">
  <img src="yourimage.png" class="z-menuitem-image" align="absmiddle">
  <span class="z-menuitem-text">Save All</span>
 </a>
</li>

Result will depend on your code, but at this point you just need to apply a bit of css to style the inner span. The code will depend on how you write it, but the general idea should be similar too:

.myCustomCssClass span{
   //style here!
}
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: 2016-09-05 05:47:10 +0800

Seen: 23 times

Last updated: Sep 06 '16

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