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/01/14 17:15:14 UTC

[royale-asjs] branch develop updated: jewel-datagrid: fix selectionChanged for the whole component

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 4993a64  jewel-datagrid: fix selectionChanged for the whole component
4993a64 is described below

commit 4993a645baf702f418c9ebed481cfe2fa9e18085
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Jan 14 18:15:01 2020 +0100

    jewel-datagrid: fix selectionChanged for the whole component
---
 .../src/main/royale/DataGridPlayGround.mxml        | 22 ++++++++++++++++++++++
 .../src/main/royale/ListPlayGround.mxml            |  8 ++++----
 .../royale/jewel/beads/views/DataGridView.as       |  9 +--------
 3 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml b/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
index 453d1ca..c991488 100644
--- a/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/DataGridPlayGround.mxml
@@ -78,6 +78,26 @@ limitations under the License.
 			// productModel.productList.removeAll();
 		}
 
+		private function describeItem(item:*):String {
+			const intro:String = "<strong>DataGrid selectedItem:</strong> ";
+			var evaluated:String;
+			if (item is String) {
+				evaluated = "String value: '" + item + "'";
+			} else {
+				if (item === null || item === undefined) {
+					evaluated = "Nothing Selected";
+				}
+				else {
+					if (item is IconListVO) {
+						evaluated = "Object's label field: '" + IconListVO(item).label + "'";
+					} else {
+						evaluated = "Object : " + item;
+					}
+				}
+			}
+			return intro + evaluated;
+		}
+
 		[Bindable]
 		public var listModel:ListsModel = new ListsModel();
 		]]>
@@ -152,6 +172,8 @@ limitations under the License.
 						<j:Button text="Remove First Row" click="removeFirstRow()"/>
 						<j:Button text="Update First Row" click="updateFirstRow()"/>
 						<j:Button text="Remove all rows" click="removeAllRows()"/>
+						<j:Label html="{'Selected Index: ' + datagrid2.selectedIndex}"/>
+						<j:Label id="selected" html="{describeItem(datagrid2.selectedItem)}"/>
 					</j:VGroup>
 				</j:HGroup>
 			</j:Card>
diff --git a/examples/royale/TourDeJewel/src/main/royale/ListPlayGround.mxml b/examples/royale/TourDeJewel/src/main/royale/ListPlayGround.mxml
index b224fd0..6563ab3 100644
--- a/examples/royale/TourDeJewel/src/main/royale/ListPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/ListPlayGround.mxml
@@ -97,16 +97,16 @@ limitations under the License.
 				const intro:String = "<strong>List selectedItem:</strong> ";
 				var evaluated:String;
 				if (item is String) {
-					evaluated = 'String value: \'' + item + '\'';
+					evaluated = "String value: '" + item + "'";
 				} else {
 					if (item === null || item === undefined) {
-						evaluated = '[Nothing Selected]'
+						evaluated = "Nothing Selected]";
 					}
 					else {
 						if (item is IconListVO) {
-							evaluated = 'Object\'s label field: \'' + IconListVO(item).label + '\'';
+							evaluated = "Object's label field: '" + IconListVO(item).label + "'";
 						} else {
-							evaluated = 'Object : ' + item;
+							evaluated = "Object : " + item;
 						}
 					}
 				}
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 0296cb4..c22cb21 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
@@ -256,6 +256,7 @@ package org.apache.royale.jewel.beads.views
                 var list:IDataGridColumnList = _lists[i] as IDataGridColumnList;
                 list.selectedIndex = newIndex;
             }
+            host.dispatchEvent(new Event('selectionChanged'));
         }
 
         /**
@@ -267,14 +268,6 @@ package org.apache.royale.jewel.beads.views
         {
             var list:IDataGridColumnList = event.target as IDataGridColumnList;
             _sharedModel.selectedIndex = list.selectedIndex;
-
-            for(var i:int=0; i < _lists.length; i++) {
-                if (list != _lists[i]) {
-                    var otherList:IDataGridColumnList = _lists[i] as IDataGridColumnList;
-                    otherList.selectedIndex = list.selectedIndex;
-                }
-            }
-
             host.dispatchEvent(new Event('change'));
         }
         /**