-
FEATURED COMPONENTS
First time here? Check out the FAQ!
In my view model, I'm programmatically creating my menupopup. One of the menuitems I'd like to make appear bold. When I try the following style application it's not working:
Menuitem idItem = new Menuitem("ID: "+content.getId());
idItem.setStyle("font-weight:bold");
Note, the API says for setStyle is http://www.zkoss.org/javadoc/8.0.0-RC/zk/org/zkoss/zk/ui/HtmlBasedComponent.html#setStyle(java.lang.String) It just says:
"Sets the CSS style."
You can define a class name bold into the <style>
component or a CSS file as below.
<style>
.bold .z-menuitem-text { font-weight: bold}
</style>
and in the java code to use idItem.setSclass("bold") instead.
If user needs to put some specific style like bold or italic then it is useful, but rather it should work like any style like color, background-color should work eg.
Menuitem idItem = new Menuitem("ID: "+content.getId()); idItem.setStyle("color:red");
When a MenuItem is created then in DOM it creates
li tag>
anchor tag>
i tag start & end
span tag start> ID: span tag ends>
anchor tag ends>
li tag ends>
And when we apply style to the MenuItem then it puts the style to li tag> rather than in span tag, hence the style property to the displayed content like Menuitem lable is not applied.
I think its design is like this or we can say its a bug.
Asked: 2015-10-07 16:12:17 +0800
Seen: 63 times
Last updated: Sep 05 '16