This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4f80199  jewel-datagrid: fix height %
4f80199 is described below

commit 4f80199b990472d6845e9f47f8268d523cf221ca
Author: Carlos Rovira <[email protected]>
AuthorDate: Sun Mar 1 11:19:32 2020 +0100

    jewel-datagrid: fix height %
---
 .../royale/jewel/beads/layouts/DataGridLayout.as   | 17 ++++++++--
 .../royale/jewel/beads/views/DataGridView.as       | 36 +++++++++++++---------
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
index 33f1f81..028066e 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/DataGridLayout.as
@@ -125,8 +125,18 @@ package org.apache.royale.jewel.beads.layouts
                        }
                        var columnWidths:Array = [];
 
+                       if(listArea.y != header.height)
+                               listArea.y = header.height;
+                       
                        (listArea as ILayoutChild).percentWidth = 100;
-            listArea.y = header.height;
+                       // (listArea as ILayoutChild).percentHeight = 100;
+                       
+                       COMPILE::JS {   
+                       if(datagrid.height == 0)
+                               listArea.positioner.style.height = "calc(100% - 
" + header.height + "px)";
+                       else
+                               listArea.height = datagrid.height - 
header.height;
+                       }
             
                        for(var i:int=0; i < bbmodel.dataProvider.length; i++) {
                                var columnDef:IDataGridColumn = 
(bbmodel.dataProvider as ArrayList).getItemAt(i) as IDataGridColumn;
@@ -137,7 +147,10 @@ package org.apache.royale.jewel.beads.layouts
                                        columnList.height = NaN;
                                } else
                                {
-                                       columnList.height = listArea.height;
+                                       if(datagrid.height == 0)
+                                               columnList.percentHeight = 100;
+                                       else
+                                               columnList.height = 
listArea.height;
                                }
 
                                //temporal- if only one 
isNaN(columnDef.columnWidth) make it true so widthType = 
ButtonBarModel.PIXEL_WIDTHS
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DataGridView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DataGridView.as
index 5fce758..33cdd9b 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DataGridView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DataGridView.as
@@ -88,8 +88,8 @@ package org.apache.royale.jewel.beads.views
 
             _dg = _strand as IDataGrid;
             _presentationModel = _dg.presentationModel as 
IDataGridPresentationModel;
-            _dg.addEventListener("widthChanged", handleSizeChanges);
-            _dg.addEventListener("heightChanged", handleSizeChanges);
+            // _dg.addEventListener("widthChanged", handleSizeChanges);
+            // _dg.addEventListener("heightChanged", handleSizeChanges);
             
             // see if there is a presentation model already in place. if not, 
add one.
             _sharedModel = _dg.model as IDataGridModel;
@@ -106,6 +106,8 @@ package org.apache.royale.jewel.beads.views
                 */
                private function createChildren():void
                {
+            listenOnStrand("initComplete", initCompleteHandler);
+
             // header
             var headerClass:Class = ValuesManager.valuesImpl.getValue(host, 
"headerClass") as Class;
             _header = new headerClass() as DataGridButtonBar;
@@ -131,10 +133,8 @@ package org.apache.royale.jewel.beads.views
             // set default width and height
             if(!_dg.width && !(_dg as ILayoutChild).percentWidth)
                 _dg.width = 220; // if width not set make it default to 220px
-            if(!_dg.height)
+            if(!_dg.height && isNaN((_dg as ILayoutChild).percentHeight))
                 _dg.height = 240; // if height not set make it default to 240px
-            
-            handleDataProviderChanged(null);
         }
 
         /**
@@ -186,6 +186,23 @@ package org.apache.royale.jewel.beads.views
         }
 
         /**
+                *  finish setup
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                *  
+         *  @param event 
+         */
+        protected function initCompleteHandler(event:Event):void
+               {
+            IEventDispatcher(_strand).removeEventListener("initComplete", 
initCompleteHandler);
+            handleDataProviderChanged(null);
+            // host.dispatchEvent(new Event("layoutNeeded"));
+        }
+
+        /**
          * An array of List objects the comprise the columns of the DataGrid.
          */
         public function get columnLists():Array
@@ -209,15 +226,6 @@ package org.apache.royale.jewel.beads.views
             return _header;
         }
 
-        /**
-         * @private
-         */
-        private function handleSizeChanges(event:Event):void
-        {
-            _listArea.height = _dg.height - _header.height;
-            dispatchEvent(new Event("layoutNeeded"));
-        }
-
         private var dp:IEventDispatcher;
         /**
          * @private

Reply via email to