0

Error in JS

asked 2005-12-28 06:27:43 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3495268

By: nobody

I got an error with java script. I do not know exactly why it came, but this is the information I have:

Problem file: zkau/web/js/i_zul.js
Line number: 1439

Snippet:
_calcSize2: function () {
....
var tblwd = this.body.clientWidth - 1;
//due to experiment, we have to substract 1 to avoid
//hor. scrollbar from appearing
if (this.headtbl) {
var extra = (this.body.offsetWidth - this.body.clientWidth) <= 5 ? 2: 0;
this.headtbl.style.width = this.head.style.width = (tblwd + extra) + 'px'; //ERROR HERE ....

In my runtime, 'this.body.clientWidth' evaluates to zero. So (tblwd + extra)
+ 'px' is -1, which gives an error saying invalid argument for width.

Is this a bug?


delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2005-12-28 08:38:39 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3495334

By: tomyeh

It shall be a bug if clientWidth will be zero. Is your listbox or tree contain no row at all?

link publish delete flag offensive edit

answered 2005-12-28 08:53:00 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3495341

By: samyem

My listbox does have rows. In anycase, I think the code should have been able to handle this situation. You can take a look at my code if that helps:
http://samyem.com/webdb.src.zip
The problem occured while rendering net.yomari.webdb.ui.TableTabBox .




link publish delete flag offensive edit

answered 2005-12-28 10:03:14 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3495398

By: tomyeh

Samyem,

I skimmed your codes. It looks OK to me. Would you post the executable or a hyper link that I can test without compiling your codes?

link publish delete flag offensive edit

answered 2005-12-28 14:46:52 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3495587

By: nobody

I didn't want to put the website in public as I have not implemented any security in the app yet. However, you can run it locally with http://www.samyem.com/webdb.zip Just put the ZK and Firebird (jaybird-full-2.0.0.jar) libs under the WEB-INF/lib folder.

link publish delete flag offensive edit

answered 2005-12-29 05:48:01 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3496613

By: nobody

You can get the same error with the following code (mind the quotes). Put this inside a Window and see the error appear. The error does not come if I do not add the header of the listbox.

Listbox myList=new Listbox();
this.appendChild(myList);

Listhead header=new Listhead();
header.setParent(myList);

Listheader nameHeader=new Listheader("Name"); header.appendChild(nameHeader);

Listheader typeHeader=new Listheader("Type"); header.appendChild(typeHeader);

Listitem columnItems=new Listitem();
myList.appendChild(columnItems);

Listcell cell=new Listcell("some label"); columnItems.appendChild(cell);

Listcell celltype=new Listcell("some type"); columnItems.appendChild(celltype);




link publish delete flag offensive edit

answered 2005-12-29 06:09:32 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3496632

By: nobody

I found the root cause of the problem. Apparently, if a listbox does not have the width specified, adding the listhead causes the java script error to occur.
This is a bug. The listbox should have taken a default width if one is not given.

link publish delete flag offensive edit

answered 2005-12-29 06:49:24 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3496659

By: tomyeh

It is fixed(the codes you posted in the last mail is really useful). It will be available at the next release.

It is, as you suggested, caused by zero width. However, the real cause is that the width is not ready yet (in IE) and we have to delay the calc.

Thus, the fix is

var wd = tblwd + ((this.body.offsetWidth - this.body.clientWidth) <= 5 ? 2: 0); if (wd < 0) wd = 0; this.headtbl.style.width = this.head.style.width = wd + 'px';


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: 2005-12-28 06:27:43 +0800

Seen: 611 times

Last updated: Dec 29 '05

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