From: Brandon King Date: Tue, 30 Jun 2009 22:43:48 +0000 (+0000) Subject: Auto resizing for grids based on collapsing and resizing of other components X-Git-Tag: 0.2.6~23 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=2cc86ce83af87a20ef9ae5670a926f5fae1b87ae Auto resizing for grids based on collapsing and resizing of other components --- diff --git a/htsworkflow/frontend/static/js/htsw-inventory.js b/htsworkflow/frontend/static/js/htsw-inventory.js index 419a80f..6f44e50 100644 --- a/htsworkflow/frontend/static/js/htsw-inventory.js +++ b/htsworkflow/frontend/static/js/htsw-inventory.js @@ -67,7 +67,7 @@ var getInventoryDataGrid = function(){ frame: true, width: 'auto', //height: 500, - autoHeight: true, + //autoHeight: true, collapsible: false, title: "Inventory Index", iconCls: 'icon-grid', diff --git a/htsworkflow/frontend/static/js/htsw.js b/htsworkflow/frontend/static/js/htsw.js index 72bead1..40ddf09 100644 --- a/htsworkflow/frontend/static/js/htsw.js +++ b/htsworkflow/frontend/static/js/htsw.js @@ -21,6 +21,20 @@ var goto_url = function(www_url) window.location = www_url; } +var RESIZEME_ARRAY = new Array(); + +var resize_registered_panel = function(pnl){ + Ext.each(RESIZEME_ARRAY, function(fnc){ + fnc(); + }); +} + +var resize_registered = function(cmp, adj_w, adj_h, raw_w, raw_h){ + Ext.each(RESIZEME_ARRAY, function(fnc){ + fnc(); + }); +} + $(document).ready(function(){ //---------------------------------------- // Django Library Page CSS Fix @@ -146,8 +160,10 @@ $(document).ready(function(){ // Main Viewport Setup //------------------------------- var mainBorderPanel = new Ext.Viewport({ + //id: 'main_viewport', layout: 'border', items: [{ + id: 'north_border_panel', region: 'north', layout: 'vBox', layoutConfig: { @@ -181,11 +197,13 @@ $(document).ready(function(){ split: true },menuPanel,{ //title: 'Body', + id: 'body_content_panel', region: 'center', xtype: 'panel', //autoScroll: true, layout: 'fit', margins: '2 0 2 0', + monitorResize: true, items: [{ //title: 'Inner Panel', contentEl: 'body_content', @@ -195,6 +213,15 @@ $(document).ready(function(){ },eastPanel] }); + // Using a little trick to resize registered components: + // i.e. just use RESIZEME_ARRAY.push(function() { }); to register a function + // to be called during these events. + mainBorderPanel.on('resize', resize_registered); + var northBorderPanel = Ext.getCmp('north_border_panel'); + northBorderPanel.on('collapse', resize_registered_panel); + northBorderPanel.on('expand', resize_registered_panel); + + //------------------------------- // Menu Bar Setup //------------------------------- @@ -284,5 +311,11 @@ $(document).ready(function(){ if (grid_target != null){ var grid = getInventoryDataGrid(); grid.render(grid_target); + RESIZEME_ARRAY.push(function() { + Ext.getCmp('inventory_item_panel').setHeight(Ext.getCmp('body_content_panel').getHeight()-4); + }); + grid.setHeight(Ext.get('body_content_panel').getHeight()-4); } + + }); \ No newline at end of file