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/11/15 20:03:23 UTC

[royale-asjs] branch develop updated: jewel-virtualdatagrid: fix issues with column heights

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 28dd1a0  jewel-virtualdatagrid: fix issues with column heights
28dd1a0 is described below

commit 28dd1a042432f0ed99f9a62c1b2d2cba72e72538
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sun Nov 15 21:03:08 2020 +0100

    jewel-virtualdatagrid: fix issues with column heights
---
 .../src/main/royale/VirtualListsPlayGround.mxml    |  6 +--
 .../src/main/royale/models/ProductModel.as         | 34 +++++++++++++++
 .../projects/Jewel/src/main/resources/defaults.css |  1 +
 .../projects/Jewel/src/main/royale/JewelClasses.as |  2 +
 .../royale/jewel/beads/views/DataGridView.as       | 11 ++++-
 .../jewel/beads/views/VirtualDataGridView.as       | 51 ++++++++++++++++++++++
 .../Jewel/src/main/sass/components/_datagrid.sass  |  1 +
 7 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/examples/jewel/TourDeJewel/src/main/royale/VirtualListsPlayGround.mxml b/examples/jewel/TourDeJewel/src/main/royale/VirtualListsPlayGround.mxml
index 05a3bc2..7479475 100644
--- a/examples/jewel/TourDeJewel/src/main/royale/VirtualListsPlayGround.mxml
+++ b/examples/jewel/TourDeJewel/src/main/royale/VirtualListsPlayGround.mxml
@@ -23,7 +23,7 @@ limitations under the License.
 	xmlns:js="library://ns.apache.org/royale/basic" 
 	xmlns:c="components.*" 
 	xmlns:models="models.*" sourceCodeUrl="VirtualListsPlayGround.mxml"
-	initComplete="listModel.createBigIconListVOData()">
+	initComplete="listModel.createBigIconListVOData(); productModel.createBigProductVOData()">
 	
 	<fx:Script>
 		<![CDATA[
@@ -169,8 +169,8 @@ limitations under the License.
             <j:Card>
 				<html:H3 text="Jewel VirtualDataGrid"/>
 				
-				<j:VirtualDataGrid localId="virtualDataGrid"
-							dataProvider="{productModel.productList}">
+				<j:VirtualDataGrid localId="virtualDataGrid" width="300" height="300"
+							dataProvider="{productModel.bigProductVOData}">
 					<j:columns>
 						<j:DataGridColumn label="Title" dataField="title"/>
 						<j:DataGridColumn label="Sales" dataField="sales"/>
diff --git a/examples/jewel/TourDeJewel/src/main/royale/models/ProductModel.as b/examples/jewel/TourDeJewel/src/main/royale/models/ProductModel.as
index a31a750..a805273 100644
--- a/examples/jewel/TourDeJewel/src/main/royale/models/ProductModel.as
+++ b/examples/jewel/TourDeJewel/src/main/royale/models/ProductModel.as
@@ -54,5 +54,39 @@ package models
 		{
 			return _productList;
 		}
+
+
+		/**
+		 * Used in the Virtual List example example.
+		 */
+		public var _bigProductVOData:ArrayList;
+        
+        public function get bigProductVOData():ArrayList
+        {
+			return _bigProductVOData;
+		}
+        public function set bigProductVOData(value:ArrayList):void
+        {
+			_bigProductVOData = value;
+		}
+
+		public function createBigProductVOData():void
+        {
+			var item:Product;
+            var dp:Array = [];
+			
+			for (var i:int = 0; i < 2000; i++)
+			{
+				item = new Product(
+					"pr"+Math.floor(Math.random()*1000), 
+					"Product - " + i, Math.floor(Math.random()*1000), 
+					Math.floor(Math.random()*1000), 
+					"assets/smallbluerect.jpg"
+				);
+				dp.push(item);
+			}
+            
+            bigProductVOData = new ArrayList(dp);
+        }
 	}
 }
diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css b/frameworks/projects/Jewel/src/main/resources/defaults.css
index a87cf91..ecbc6a4 100644
--- a/frameworks/projects/Jewel/src/main/resources/defaults.css
+++ b/frameworks/projects/Jewel/src/main/resources/defaults.css
@@ -554,6 +554,7 @@ j|DataGridButtonBar {
 }
 
 j|VirtualDataGrid {
+  IBeadView: ClassReference("org.apache.royale.jewel.beads.views.VirtualDataGridView");
   columnClass: ClassReference("org.apache.royale.jewel.supportClasses.datagrid.VirtualDataGridColumnList");
 }
 
diff --git a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
index 79d474b..d4c1f0a 100644
--- a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
+++ b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as
@@ -118,6 +118,8 @@ import org.apache.royale.utils.observeElementSize;
         import org.apache.royale.jewel.beads.views.DataGridView; DataGridView;
         import org.apache.royale.jewel.beads.layouts.DataGridLayout; DataGridLayout;
         
+        import org.apache.royale.jewel.beads.views.VirtualDataGridView; VirtualDataGridView;
+        
         import org.apache.royale.jewel.supportClasses.LayoutProxy; LayoutProxy;
 
         import org.apache.royale.jewel.supportClasses.util.positionInsideBoundingClientRect; positionInsideBoundingClientRect;
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 fe1fbd1..1dee93e 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
@@ -78,7 +78,7 @@ package org.apache.royale.jewel.beads.views
             super();
         }
 
-        private var _dg:IDataGrid = _strand as IDataGrid;
+        protected var _dg:IDataGrid = _strand as IDataGrid;
         private var _header:IDataGridHeader;
         private var _listArea:IUIBase;
         private var _lists:Array = [];
@@ -239,6 +239,8 @@ package org.apache.royale.jewel.beads.views
                 list.addEventListener('selectionChanged', handleColumnListSelectionChange);
                 list.addEventListener('beadsAdded', configureColumnListPresentationModel);
                 (list as StyledUIBase).tabIndex = -1;
+                setColumnHeight(list as StyledUIBase);
+                
 
                 (_listArea as IParent).addElement(list as IChild);
 
@@ -247,6 +249,13 @@ package org.apache.royale.jewel.beads.views
         }
 
         /**
+         * set the height of the column if necessary
+         */
+        protected function setColumnHeight(column:StyledUIBase):void {
+            // override in subclasses if necessary - VirtualDataGrid needs to use this since it can't left height unset
+        }
+
+        /**
          * @private
          */
         protected function configureColumnListPresentationModel(event:Event):void
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualDataGridView.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualDataGridView.as
new file mode 100644
index 0000000..3cca9b3
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualDataGridView.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.jewel.beads.views
+{    
+    import org.apache.royale.core.StyledUIBase;
+
+    /**
+     *  The VirtualDataGridView class is the visual bead for Jewel VirtualDataGrid.
+     *  
+     *  @viewbead
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.8
+     */
+    public class VirtualDataGridView extends DataGridView
+    {
+        /**
+         *  constructor.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.8
+         */
+        public function VirtualDataGridView()
+        {
+            super();
+        }
+
+        override protected function setColumnHeight(column:StyledUIBase):void {
+            column.height = _dg.height - header.height;
+        }
+    }
+}
\ No newline at end of file
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass b/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass
index 74baf38..30bb170 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_datagrid.sass
@@ -86,6 +86,7 @@ j|DataGridButtonBar
 
 
 j|VirtualDataGrid
+    IBeadView: ClassReference("org.apache.royale.jewel.beads.views.VirtualDataGridView")
     columnClass: ClassReference("org.apache.royale.jewel.supportClasses.datagrid.VirtualDataGridColumnList")   
 
 j|VirtualDataGridColumnList