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 de3e8ed jewel-datagrid: removed default height. If height is not provided component measures to the num rows * rowHeight. de3e8ed is described below commit de3e8edd45445e94b3a838edda46f6b7ac0ebc37 Author: Carlos Rovira <carlosrov...@apache.org> AuthorDate: Sun Mar 8 01:57:46 2020 +0100 jewel-datagrid: removed default height. If height is not provided component measures to the num rows * rowHeight. --- .../projects/Jewel/src/main/resources/defaults.css | 3 +- .../royale/org/apache/royale/jewel/DataGrid.as | 4 +-- .../royale/jewel/beads/layouts/DataGridLayout.as | 38 ++++++++++++++-------- .../royale/jewel/beads/views/DataGridView.as | 4 +-- .../Jewel/src/main/sass/components/_datagrid.sass | 3 +- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css b/frameworks/projects/Jewel/src/main/resources/defaults.css index 75433bf..f443e42 100644 --- a/frameworks/projects/Jewel/src/main/resources/defaults.css +++ b/frameworks/projects/Jewel/src/main/resources/defaults.css @@ -515,7 +515,7 @@ j|VirtualComboBoxPopUp { } .jewel.datagrid .listarea { width: 100%; - height: 100%; + flex: 1 1 0%; } .jewel.datagrid .jewel.list.column .jewel.item.datagrid { width: 100%; @@ -543,6 +543,7 @@ j|DataGridColumnList { IItemRendererClassFactory: ClassReference("org.apache.royale.core.SelectableItemRendererClassFactory"); IItemRenderer: ClassReference("org.apache.royale.jewel.itemRenderers.DataGridItemRenderer"); ISelectableItemRenderer: ClassReference("org.apache.royale.jewel.beads.itemRenderers.ClassSelectorListSelectableItemRendererBead"); + IViewport: ClassReference("org.apache.royale.jewel.supportClasses.Viewport"); } .jewel.datechooser .jewel.table { 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 4782833..ac9e6f4 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 @@ -63,11 +63,9 @@ package org.apache.royale.jewel super(); typeNames = "jewel datagrid"; - // set default width and height + // 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 - if(isHeightSizedToContent()) - height = 240; // if height not set make it default to 240px } [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 4ecaf31..9fe4c93 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 @@ -21,7 +21,6 @@ package org.apache.royale.jewel.beads.layouts import org.apache.royale.collections.ArrayList; import org.apache.royale.core.IBeadLayout; import org.apache.royale.core.IDataGridModel; - import org.apache.royale.core.IScrollingViewport; import org.apache.royale.core.IStrand; import org.apache.royale.core.IUIBase; import org.apache.royale.core.UIBase; @@ -31,7 +30,6 @@ package org.apache.royale.jewel.beads.layouts import org.apache.royale.html.beads.models.ButtonBarModel; import org.apache.royale.jewel.supportClasses.datagrid.IDataGridColumn; import org.apache.royale.jewel.supportClasses.datagrid.IDataGridPresentationModel; - import org.apache.royale.jewel.supportClasses.scrollbar.ScrollingViewport; /** * DataGridLayout is a class that handles the size and positioning of the @@ -86,6 +84,11 @@ package org.apache.royale.jewel.beads.layouts { layout(); } + + /** + * Used at begining of layout for % height + */ + private var initLayout:Boolean = true; /** * @copy org.apache.royale.core.IBeadLayout#layout @@ -99,6 +102,21 @@ package org.apache.royale.jewel.beads.layouts */ public function layout():Boolean { + var model:IDataGridModel = datagrid.model as IDataGridModel; + + // required when using percentage height (%) since at this point still don't have component measure + // so we call requestAnimationFrame until get right values + COMPILE::JS + { + if(initLayout && model.dataProvider){ + if(datagrid.height == 0 && !isNaN(datagrid.percentHeight)) { + requestAnimationFrame(layout); + return true; + } else + initLayout = false; + } + } + var view:IDataGridView = datagrid.view as IDataGridView var presentationModel:IDataGridPresentationModel = datagrid.getBeadByType(IDataGridPresentationModel) as IDataGridPresentationModel; var header:IUIBase = view.header; @@ -109,10 +127,9 @@ package org.apache.royale.jewel.beads.layouts var bblayout:ButtonBarLayout = header.getBeadByType(ButtonBarLayout) as ButtonBarLayout; // (header as ButtonBar).widthType = ButtonBarModel.PROPORTIONAL_WIDTHS; var listArea:IUIBase = view.listArea; - var scrollbead:ScrollingViewport = listArea.getBeadByType(IScrollingViewport) as ScrollingViewport; var displayedColumns:Array = view.columnLists; - var model:IDataGridModel = datagrid.model as IDataGridModel; + // Width var defaultColumnWidth:Number; @@ -129,16 +146,14 @@ package org.apache.royale.jewel.beads.layouts { 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; - scrollbead.scroll = true; } else { columnList.percentHeight = 100; - scrollbead.scroll = false; } //temporal- if only one isNaN(columnDef.columnWidth) make it true so widthType = ButtonBarModel.PIXEL_WIDTHS @@ -161,16 +176,13 @@ package org.apache.royale.jewel.beads.layouts if(pixelflag) { bblayout.widthType = ButtonBarModel.PIXEL_WIDTHS; - COMPILE::JS - { - datagrid.width = NaN; - listArea.width = NaN; - } + datagrid.width = NaN; + listArea.width = NaN; } header.dispatchEvent(new Event("layoutNeeded")); listArea.dispatchEvent(new Event("layoutNeeded")); - + return true; } } 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 ec7ddd5..d3e9904 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,7 @@ 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 as ILayoutChild).percentHeight = 100; list.itemRenderer = dataGridColumn.itemRenderer; list.labelField = dataGridColumn.dataField; list.addEventListener('rollOverIndexChanged', handleColumnListRollOverChange); @@ -250,7 +250,7 @@ package org.apache.royale.jewel.beads.views if(!layout) { // Load the layout bead if it hasn't already been loaded (init time) layout = loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", _strand) as IBeadLayout; - } + } host.dispatchEvent(new Event("layoutNeeded")); } diff --git a/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass b/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass index 2b42549..3f29691 100644 --- a/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass +++ b/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass @@ -31,7 +31,7 @@ .listarea width: 100% - height: 100% + flex: 1 1 0% .jewel.list.column @@ -64,6 +64,7 @@ j|DataGridColumnList IItemRendererClassFactory: ClassReference("org.apache.royale.core.SelectableItemRendererClassFactory") IItemRenderer: ClassReference("org.apache.royale.jewel.itemRenderers.DataGridItemRenderer") ISelectableItemRenderer: ClassReference("org.apache.royale.jewel.beads.itemRenderers.ClassSelectorListSelectableItemRendererBead") + IViewport: ClassReference("org.apache.royale.jewel.supportClasses.Viewport") //Nothing to change from j|ButtonBar j|DataGridButtonBar