« Return to Thread: Automatically resize a qx.ui.form.List according to the number of contained items

Re: Automatically resize a qx.ui.form.List according to the number of contained items

by Alexander Back :: Rate this Message:

Reply to Author | View in Thread

Hi Jean-Noel,

On Monday 22 June 2009 Jean-Noël Rivasseau wrote:
> Pretty much everything is in the title: I have a qx.ui.form.List which is a
> acting as a selector. I put a number of entries in it, and I would like the
> box's height to be automatically computed. Currently it seems it chooses a
> default height. Manually calling setHeight() works, but is not convenient
> (I dont know the exact height).
>
> Ideally I would like it to resize automatically when adding or removing
> items to this list.
Normally the list widget shows scrollbars and since this is the default
behaviour you need to do some extra lifting to getting things done.

First you can use the "addItem" and "removeItem" events to get informed that
an list item was added / removed.

You can attach a listener method with the following code

--snip--
// "this" refers to the list widget

var containerHeight = this.getChildrenContainer().getSizeHint().height;
this.setHeight(containerHeight + (this.getInsets().top * 2) + 16);
--snip--

Don't ask me where the "16" pixels coming from. I simply played with the
values to prevent the scrollbar to be shown.

Hope that helps,
  Alex



------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

 « Return to Thread: Automatically resize a qx.ui.form.List according to the number of contained items