Hi Daniel,
> to accomplish this I guess you'd have to calculate the total height the 
> table would need to display its content and then set the table widget's 
> height to that value.
> You can get the table's rowHeight and multiply that with the table 
> model's rowCount, then add the table's headerCellHeight. If your table 
> has a statusBar, you could access it through the table's _getChildren() 
> method, get its height using the getSizeHint() method and add that as well.
>   
The following code works for me. I've got 2 questions now. Isn't there a
easy way to set the table's height to flex or something and make it grow
vertically automatically?

And how to do I reset the minHeight for the parent container when the
table is not visible to the user, like when I close/destroy the table,
or the user switches to the 2nd tab?

> qx.Class.define("testproject.Application",
> {
>   extend : qx.application.Standalone,
>
>
>
>   /*
>  
> *****************************************************************************
>      MEMBERS
>  
> *****************************************************************************
>   */
>
>   members :
>   {
>     /**
>      * This method contains the initial application code and gets called
>      * during startup of the application
>      */
>     __getTable  : function(){
>       var tableModel = this._tableModel = new qx.ui.table.model.Simple();
>       tableModel.setColumns([ "Col1", "Col2", "Col3", "Col4" ]);
>       //var rowData = this.__createRandomRows(50);
>       var rowData =
> this.__createRandomRows(this.per_table_field.getSelection()[0].getLabel());
>       tableModel.setData(rowData);
>       
>       // table
>       var table = new qx.ui.table.Table(tableModel);
>      
> table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION);
>       
>       //set table height to the full height needed for the table
>       /*...*/
>       tableModel.addListener("dataChanged", this.setTableSize, this);
>       table.addListener("appear", this.setTableSize, this);
>       return table;
>     },
>      
>     setTableSize : function(e)
>     {
>        var model = this.table.getTableModel();
>        var tableHeight = (model.getRowCount() *
>         this.table.getRowHeight()) + this.table.getHeaderCellHeight();
>        // get the status bar's height
>        var tableChildren = this.table._getChildren();
>        for (var i = 0, l = tableChildren.length; i < l; i++) {
>          if (tableChildren[i].classname == "qx.ui.basic.Label") {
>            var childHeight = tableChildren[i].getSizeHint().height
>            this.debug("Adding label's height of:" + childHeight + " ...");
>            tableHeight += childHeight;
>          }
>        }
>        tableHeight += 24;
>        var increase = tableHeight - this.table.getBounds().height;
>        var child_original_height =
> this.child_container.getBounds().height;
>        var containerHeight = child_original_height + increase;
>        //var containerHeight = tableHeight + 200;
>        this.debug("Setting table height to " + tableHeight + " ...");
>        this.debug("Increasing child container by " + increase + " from
> " + child_original_height + " to "
>          + containerHeight + " ...");
>        
>        this.table.setMinHeight(tableHeight);
>        //this.tab_container.setMinHeight(tableHeight)
>        this.child_container.setMinHeight(containerHeight);
>     },
>     
>     __createRandomRows : function(rowCount)
>     {
>       var rowData = [];
>       var now = new Date().getTime();
>       var dateRange = 400 * 24 * 60 * 60 * 1000; // 400 days
>       for (var row = 0; row < rowCount; row++) {
>         var date = new Date(now + Math.random() * dateRange -
> dateRange / 2);
>         rowData.push([ date, row, Math.random() * 10000,
> (Math.random() > 0.5).toString() ]);
>       }
>       return rowData;
>     },
>     
>     main  : function()
>     {
>       this.base(arguments);
>       /* Set locale to english to avoid language mix if browser locale is
>        * non-english. */
>       qx.locale.Manager.getInstance().setLocale("en");      
>
>       if (qx.core.Variant.isSet("qx.debug", "on"))
>       {
>         // support native logging capabilities, e.g. Firebug for Firefox
>         qx.log.appender.Native;
>
>         // support cross-browser console. Press F7 to toggle visibility
>         qx.log.appender.Console;
>       }
>       
>       //create a scrollbar based container, so that vertical space
> isn't a problem from now on
>       this.scroll = new qx.ui.container.Scroll();
>       this.scroll.set({padding: 10});
>       this.getRoot().add(this.scroll, {edge: 0});
>       
>       //create a composite container to hold login box, tab view etc now
>       var layout = new qx.ui.layout.VBox;
>       layout.setSeparator("separator-vertical");
>       layout.setSpacing(5);
>       this.child_container = new qx.ui.container.Composite();
>       CONT = this.child_container;
>       //have a min height and width
>       this.scroll.add(this.child_container.set({
>         minWidth: 960,
>         minHeight: 800
>       }), {edge : 10, flex: 1});
>       this.child_container.setLayout(layout);
>       
>       this.tab_container = new qx.ui.tabview.TabView;
>       var tab_page_layout = new qx.ui.layout.VBox;
>       this.tab_page_container = new qx.ui.tabview.Page("Tab Page");
>       this.second_page_container = new qx.ui.tabview.Page("2nd Page");
>       var second_page_layout = new qx.ui.layout.VBox;
>       this.tab_page_container.setLayout(tab_page_layout);
>       
>       //second page stuff
>       this.second_page_container.setLayout(second_page_layout);
>       this.second_page_container.add(new qx.ui.basic.Label("I'm a
> label"));
>       var per_table_choices = ['10','20','25','30','40','50','75','100'];
>       var per_table_field = new qx.ui.form.SelectBox();
>       per_table_field.setWidth(60);
>       for (var j=0; j < per_table_choices.length; j++)
>       {
>         var tempItem = new qx.ui.form.ListItem().set({label :
> per_table_choices[j]});
>         per_table_field.add(tempItem);
>       }
>       per_table_field.addListener("changeSelection", function(e) {
>         this.debug("ChangeSelection: " + e.getData()[0].getLabel());
>         var rowData = this.__createRandomRows(e.getData()[0].getLabel());
>         this._tableModel.setData(rowData);
>       }, this);
>       this.second_page_container.add(per_table_field);
>       this.per_table_field = per_table_field;
>       //end of second page
>       
>       this.tab_container.add(this.tab_page_container, {flex: 1});
>       this.tab_container.add(this.second_page_container, {flex: 1});
>       
>       this.table = this.__getTable();
>       this.tab_page_container.add(this.table, {flex: 1});
>       this.child_container.add(this.tab_container, {flex: 1});
>     }
>   }
> });


cheers,
skar.

-- 
--
The life so short, the craft so long to learn. 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to