Hi Jean-Noel,

here is a small code snippet which works in qooxdoo playground to give you a 
example solution for your problem:

// Document is the application root
var doc = this.getRoot();
var list = new qx.ui.form.List();
for (var i = 0; i < 15; i++) {
  list.add(new qx.ui.form.ListItem("item " +i));
}

doc.add(list, {top : 20, left : 20});

//function to resize the list
var resizeList = function(e) {
  //this refers to the list
  qx.event.Timer.once(function() {
    var listChilds = this.getChildren();
    var lastChild = listChilds[listChilds.length - 1];
    this.setHeight(this.getItemBottom(lastChild) + 4);
  }, this, 20);
}

list.addListener("appear", resizeList); //resize when list appears
list.addListener("addItem", resizeList); //resize if item was added
list.addListener("removeItem", resizeList); //resize if item was removed

var addButton = new qx.ui.form.Button("append new item");
addButton.addListener("execute", function(e) {
  list.add(new qx.ui.form.ListItem("new item"));
});
doc.add(addButton, {top : 20, left : 150});
var removeButton = new qx.ui.form.Button("remove first item");
removeButton.addListener("execute", function(e) {
  list.remove(list.getChildren()[0]);
});
doc.add(removeButton, {top : 50, left : 150});


Regards,
Andreas

Von: Jean-Noël Rivasseau [mailto:[email protected]] 
Gesendet: Montag, 22. Juni 2009 17:40
An: qooxdoo Development
Betreff: [qooxdoo-devel] Automatically resize a qx.ui.form.List according tothe 
number of contained items

Hi,

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.

I tried a lot of things but none worked, I am quite stuck right now.

Jean-Noel
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to