0

Calculate how many lines fits in a listbox

asked 2012-10-15 11:29:05 +0800

Neus gravatar image Neus
1415 14

Hi,
I'm trying to calculate how many lines fits in a listbox using javascript.
I can obtain the height of the listbox, the height of one line and with these data make the calculation.
My problem is that I can't listen when the listbox is resized. I'm able to know when the browser is resized but sometimes the listbox is resized for other reasons (another component that expands and do the listbox smaller, etc.

Is there a way to know when the height of a listbox has changed??
How does ZK know it?? (because they are recalculating how many lines fits in a listbox everytime the listbox is resized)

Thank you!

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2012-11-05 02:31:13 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi Neus,

The only way is to override the client onSize function, when the listbox resize, the onSize function will be call

listbox.setWidgetOverride("onSize", 
	"function () {this.$onSize();zk.log('onSize');}");

link publish delete flag offensive edit

answered 2012-11-05 10:10:19 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi

I have one more question here. It is possible to show the empty record lines in the list if there are only fewer records in the list. Say for example
I have fixed height for the list box and from the DB, it shows the records and assume that we have only 3 records. So the remaining space will show as blank. Can
we show empty lines without much code ?

Regards
Senthil M

link publish delete flag offensive edit

answered 2012-11-06 09:43:38 +0800

Neus gravatar image Neus
1415 14

Thank you jimmy!

link publish delete flag offensive edit

answered 2012-11-07 01:42:08 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi Senthil,
Do you mean this feature?
http://books.zkoss.org/wiki/ZK_Component_Reference/Data/Listbox#Show_messages_when_empty

link publish delete flag offensive edit

answered 2012-11-07 03:10:56 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

No. Look at the picture. It shows only one record and also it shows empty records for better look and feel.

link publish delete flag offensive edit

answered 2012-11-09 02:13:21 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

You need to add empty data to the listModel, otherwise listbox/grid only render the data in the model.

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: 2012-10-15 11:29:05 +0800

Seen: 125 times

Last updated: Nov 09 '12

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