You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2020/03/09 11:11:32 UTC

[royale-asjs] branch develop updated: jewel-datagrid: solve different columnWidths. Also remove default dg.width.

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 07c5eed  jewel-datagrid: solve different columnWidths. Also remove default dg.width.
07c5eed is described below

commit 07c5eed69f4498a816e402ed199582c5c27c24d5
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Mon Mar 9 12:10:59 2020 +0100

    jewel-datagrid: solve different columnWidths. Also remove default dg.width.
---
 .../royale/org/apache/royale/jewel/DataGrid.as     |  4 --
 .../royale/jewel/beads/layouts/DataGridLayout.as   | 54 +++++++++-------------
 .../royale/jewel/beads/views/DataGridView.as       |  1 -
 3 files changed, 23 insertions(+), 36 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DataGrid.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DataGrid.as
index ac9e6f4..ec777a9 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DataGrid.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DataGrid.as
@@ -62,10 +62,6 @@ package org.apache.royale.jewel
 		{
 			super();
 			typeNames = "jewel datagrid";
-
-			// set default width (no height, to allow be indicated by content rows)
-            if(isWidthSizedToContent())
-            	width = 220; // if width not set make it default to 220px
 		}
 		
 		[Bindable("columnsChanged")]
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 4ce3ed0..50bf70c 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
@@ -126,60 +126,52 @@ package org.apache.royale.jewel.beads.layouts
             // of columns that may contain invisible columns
             var bbmodel:ButtonBarModel = header.getBeadByType(ButtonBarModel) as ButtonBarModel;
             var bblayout:ButtonBarLayout = header.getBeadByType(ButtonBarLayout) as ButtonBarLayout;
-			// (header as ButtonBar).widthType = ButtonBarModel.PROPORTIONAL_WIDTHS;
 			var listArea:IUIBase = view.listArea;
 			
 			var displayedColumns:Array = view.columnLists;
 			
-			
 			// Width
 			var defaultColumnWidth:Number;
-			if(!datagrid.percentWidth)
-			{
-				defaultColumnWidth = (datagrid.width) / bbmodel.dataProvider.length;
-			} else
-			{
-				defaultColumnWidth = (datagrid.percentWidth) / bbmodel.dataProvider.length;
-			}
+
+			if(datagrid.percentWidth)
+				defaultColumnWidth = datagrid.percentWidth / bbmodel.dataProvider.length;
+			else
+				defaultColumnWidth = datagrid.width / bbmodel.dataProvider.length;
+			
+			// special case when no width is set at all, defaultColumnWidth will be 0
+			if(defaultColumnWidth == 0 && datagrid.isWidthSizedToContent())
+				defaultColumnWidth = 80;
+			
 			var columnWidths:Array = [];
 
 			for(var i:int=0; i < bbmodel.dataProvider.length; i++)
 			{
 				var columnDef:IDataGridColumn = (bbmodel.dataProvider as ArrayList).getItemAt(i) as IDataGridColumn;
 				var columnList:UIBase = displayedColumns[i] as UIBase;
-				
-				//remove columns height if rows not surround datagrid height (and this one is set to pixels)
-				if(model.dataProvider && (model.dataProvider.length * presentationModel.rowHeight) > (datagrid.height - header.height))
-				{
-					columnList.height = NaN;
-				} else 
-				{
-					columnList.percentHeight = 100;
-				}
-
-				//temporal- if only one isNaN(columnDef.columnWidth) make it true so widthType = ButtonBarModel.PIXEL_WIDTHS
-				var pixelflag:Boolean = false;
 				var columnWidth:Number = defaultColumnWidth;
+				
+				// Column's Width
+				// if just one isNaN(columnDef.columnWidth) make it true so widthType = ButtonBarModel.PIXEL_WIDTHS
 				if (!isNaN(columnDef.columnWidth)) {
 					columnWidth = columnDef.columnWidth;
-					pixelflag = true;
+					bblayout.widthType = ButtonBarModel.PIXEL_WIDTHS;
 				}
 				
-				if(!datagrid.percentWidth)
-					columnList.width = columnWidth;
-				else
+				if(datagrid.percentWidth)
 					columnList.percentWidth = columnWidth;
+				else
+					columnList.width = columnWidth;
 
 				columnWidths.push(columnWidth);
+				
+				// Column's Height - remove columns height if rows not surround datagrid height (and this one is set to pixels)
+				if(model.dataProvider && (model.dataProvider.length * presentationModel.rowHeight) > (datagrid.height - header.height))
+					columnList.height = NaN;
+				else 
+					columnList.percentHeight = 100;
 			}
 
 			bbmodel.buttonWidths = columnWidths;
-			if(pixelflag)
-			{
-				bblayout.widthType = ButtonBarModel.PIXEL_WIDTHS;
-				datagrid.width = NaN;
-				listArea.width = NaN;
-			}
 			
 			header.dispatchEvent(new Event("layoutNeeded"));
 			listArea.dispatchEvent(new Event("layoutNeeded"));
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 d3e9904..6a75b86 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
@@ -162,7 +162,6 @@ package org.apache.royale.jewel.beads.views
                 
                 // by default make columns get the 1/n of the maximun space available
                 (list as ILayoutChild).percentWidth = 100 / _sharedModel.columns.length;
-                // (list as ILayoutChild).percentHeight = 100;
                 list.itemRenderer = dataGridColumn.itemRenderer;
                 list.labelField = dataGridColumn.dataField;
                 list.addEventListener('rollOverIndexChanged', handleColumnListRollOverChange);