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 15:29:21 UTC
[royale-asjs] branch develop updated: jewel-datagrid: solve a case
when width could grow due to more evaluations of "columnWidth"
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 7e8f096 jewel-datagrid: solve a case when width could grow due to more evaluations of "columnWidth"
7e8f096 is described below
commit 7e8f096c3a4c8d222d3f5736f67bc27d2826e4b9
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Mon Mar 9 16:29:10 2020 +0100
jewel-datagrid: solve a case when width could grow due to more evaluations of "columnWidth"
---
.../royale/jewel/beads/layouts/DataGridLayout.as | 31 ++++++++++++++--------
1 file changed, 20 insertions(+), 11 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 50bf70c..49c2dc3 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
@@ -131,24 +131,29 @@ package org.apache.royale.jewel.beads.layouts
var displayedColumns:Array = view.columnLists;
// Width
- var defaultColumnWidth:Number;
+ var defaultColumnWidth:Number = 0;
- 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;
+ // When still don't have header buttonWidths, we need a defaultColumnWidth
+ if(!bbmodel.buttonWidths)
+ {
+ 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 = [];
+ var totalWidth:Number = 0;
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;
- var columnWidth:Number = defaultColumnWidth;
+ var columnWidth:Number = defaultColumnWidth != 0 ? defaultColumnWidth : bbmodel.buttonWidths[i];
// Column's Width
// if just one isNaN(columnDef.columnWidth) make it true so widthType = ButtonBarModel.PIXEL_WIDTHS
@@ -161,7 +166,8 @@ package org.apache.royale.jewel.beads.layouts
columnList.percentWidth = columnWidth;
else
columnList.width = columnWidth;
-
+
+ totalWidth += columnWidth;
columnWidths.push(columnWidth);
// Column's Height - remove columns height if rows not surround datagrid height (and this one is set to pixels)
@@ -173,6 +179,9 @@ package org.apache.royale.jewel.beads.layouts
bbmodel.buttonWidths = columnWidths;
+ if(isNaN(datagrid.percentWidth))
+ datagrid.width = totalWidth;
+
header.dispatchEvent(new Event("layoutNeeded"));
listArea.dispatchEvent(new Event("layoutNeeded"));