0

Change zclass css property from java code

asked 2010-05-29 23:50:16 +0800

kapil4ya gravatar image kapil4ya
172 2

Hi,

I am using my own zclass for listitems. On a particular action I am changing the zclass of the listitem according to my need.
My listbox can be check marked and multiple selectable. But when I apply my own zclass, the check box appearing on the list item can not be checked. I click on the checkbox but nothing happens.

Here is my zclass for the listitem :


.invisible{
			background-color : #FFCCCC;
		}		
		.invisible-seld {
			background-color : #FFCCCC;
		}
		.invisible-over {
			background-color : #F8F0D2;
		}
		.invisible-over-seld {
			background-color : #FFEFB2;
		}
		.invisible-img{
		
		background:none no-repeat scroll center center transparent;
        border:0 none;
        display:inline-block;
        height:13px;
        margin:2px;
        min-height:13px;
        overflow:hidden;
        padding:0;
        vertical-align:top;
        width:13px;
		
		}
		.invisible-img-checkbox {
		
		   background-image:url("/SmartHopper/zkau/web/721ea1/zul/img/common/check-sprite.gif");
                   background-position:0 0;
		}



I think I will have to change the CSS property

background-position:0 0; to background-position: -26px 0;


Am I correct ? But, I seem to have no idea how it will be done. And, even if I can do this but at what event I need to change the CSS property so that when listitem's checkbox is checked this property changes.

Thanks

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2010-05-30 22:05:35 +0800

kapil4ya gravatar image kapil4ya
172 2

Still no luck...

link publish delete flag offensive edit

answered 2010-05-31 21:19:13 +0800

PeterKuo gravatar image PeterKuo
481 2

Yes you have to modify the background position just like how zk does.

You should prepare different css for checkbox checked and unchecked.
And modify the zclass accordingly.

You may refer to
http://docs.zkoss.org/wiki/Client_Side_Programming

link publish delete flag offensive edit

answered 2010-06-01 00:14:45 +0800

kapil4ya gravatar image kapil4ya
172 2

Oh thanks Peter,

I have one question though, as I see the list item checkbox is not a check box, but an image. How do I listen to the click event and determine now I have to set the image as checked and not it's time to change the background position such that image looks like a checkbox that hasn't been checked.

Thank you.

link publish delete flag offensive edit

answered 2010-06-03 08:01:13 +0800

kapil4ya gravatar image kapil4ya
172 2

How does ZK modify the background position? Please can someone let me know if it is even possible to change the zclass at runtime?
Otherwise, I will have to go for other option.

link publish delete flag offensive edit

answered 2010-06-03 22:01:17 +0800

PeterKuo gravatar image PeterKuo
481 2

You can look into the source code of
ItemWidget.js

ZK change the class like jQuery, use removeClass() and addClass()

_toggleEffect: function (undo) {
var n = this.$n(),
zcls = this.getZclass();
if (undo) {
jq(n).removeClass(zcls + "-over-seld")
.removeClass(zcls + "-over");
} else {
var $n = jq(n);
$n.addClass($n.hasClass(zcls + "-seld") ? zcls + "-over-seld" : zcls + "-over");
}
},

link publish delete flag offensive edit

answered 2010-06-03 22:02:33 +0800

PeterKuo gravatar image PeterKuo
481 2

As to how to listen the event, please refer to
http://docs.zkoss.org/wiki/Widget_and_DOM_Events

link publish delete flag offensive edit

answered 2010-06-07 05:38:54 +0800

kapil4ya gravatar image kapil4ya
172 2

updated 2010-06-08 01:45:24 +0800

Peter, thanks for your reply.

To listen to the event, I gotta have access to the html element generated by ZK, and in this case the listcell is converted by ZK to a td and the td has children - a div and a span. This span is basically representing the checkbox, and I can not get to this span. If I try to get the list cells children, I don't get the HtmlNativeComponent with tag name span.

So, eventually, I can not reach the span and hence can not listen for the event.

Any thoughts?

link publish delete flag offensive edit

answered 2010-06-08 20:41:16 +0800

PeterKuo gravatar image PeterKuo
481 2

From
http://docs.zkoss.org/wiki/Client_Side_Programming
You can see
Widget -- See the usage of $f(), $n(), bind_(), $()

http://www.zkoss.org/javadoc/latest/jsdoc/zk/Widget.html
$n()
Returns the DOM element that this widget is bound to.

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-05-29 23:50:16 +0800

Seen: 1,204 times

Last updated: Jun 08 '10

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