You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pe...@apache.org on 2017/12/08 15:16:43 UTC
[royale-asjs] branch develop updated: Updated the ListExample to
demonstrate the Dynamic itemRenderer factory and related remove
itemRenderer bead.
This is an automated email from the ASF dual-hosted git repository.
pent 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 5f91ace Updated the ListExample to demonstrate the Dynamic itemRenderer factory and related remove itemRenderer bead.
5f91ace is described below
commit 5f91acec0185deb4e5664b2e00b16743277a4882
Author: Peter Ent <pe...@apache.org>
AuthorDate: Fri Dec 8 10:17:05 2017 -0500
Updated the ListExample to demonstrate the Dynamic itemRenderer factory and related remove itemRenderer bead.
---
.../ListExample/src/main/royale/MyInitialView.mxml | 39 ++++++++++++++++++++--
.../src/main/royale/models/ProductsModel.as | 14 ++++++--
2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/examples/royale/ListExample/src/main/royale/MyInitialView.mxml b/examples/royale/ListExample/src/main/royale/MyInitialView.mxml
index 1268666..872b0af 100644
--- a/examples/royale/ListExample/src/main/royale/MyInitialView.mxml
+++ b/examples/royale/ListExample/src/main/royale/MyInitialView.mxml
@@ -41,17 +41,47 @@ limitations under the License.
height: 30px;
}
</fx:Style>
+
+ <fx:Script>
+ <![CDATA[
+ import models.ProductsModel;
+
+ private function addState():void
+ {
+ (applicationModel as ProductsModel).states.addItemAt("New Jersey", 2);
+ }
+
+ private function removeState():void
+ {
+ (applicationModel as ProductsModel).states.removeItemAt(2);
+ }
+
+ private function addFuzzies():void
+ {
+ (applicationModel as ProductsModel).productNames.addItemAt("Fuzzies", 2);
+ }
+ ]]>
+ </fx:Script>
<js:Label x="20" y="20" text="A Royale List" />
- <js:List x="20" y="40" width="400" height="300">
+ <js:List id="list" x="20" y="40" width="400" height="300">
<js:beads>
<js:ConstantBinding
sourceID="applicationModel"
- sourcePropertyName="productNames"
+ sourcePropertyName="states"
destinationPropertyName="dataProvider" />
+ <!-- Use this dynamic itemRenderer factory when the data is an ArrayList and
+ you want to insert items programmatically. -->
+ <js:DynamicItemsRendererFactoryForArrayListData />
+ <!-- If you need to dynamically remove items from the ArrayList, include this
+ bead which removes the corresponding itemRenderer. -->
+ <js:DynamicRemoveItemRendererForArrayListData />
</js:beads>
</js:List>
+
+ <js:TextButton text="Add New Jersey" x="20" y="350" click="addState()" />
+ <js:TextButton text="Remove Item 0" x="200" y="350" click="removeState()" />
<js:Label x="500" y="20" text="A local list using DataContainer" />
@@ -62,7 +92,12 @@ limitations under the License.
sourceID="applicationModel"
sourcePropertyName="productNames"
destinationPropertyName="dataProvider" />
+ <!-- you also add this itemRendererFactory if your DataContainer list
+ is using an ArrayList as its dataProvider -->
+ <js:DynamicItemsRendererFactoryForArrayListData />
</gen:beads>
</gen:GenericList>
+
+ <js:TextButton text="Add Fuzzies" x="500" y="350" click="addFuzzies()" />
</js:View>
diff --git a/examples/royale/ListExample/src/main/royale/models/ProductsModel.as b/examples/royale/ListExample/src/main/royale/models/ProductsModel.as
index d1430b2..7fb4606 100644
--- a/examples/royale/ListExample/src/main/royale/models/ProductsModel.as
+++ b/examples/royale/ListExample/src/main/royale/models/ProductsModel.as
@@ -18,15 +18,25 @@
////////////////////////////////////////////////////////////////////////////////
package models
{
+ import org.apache.royale.collections.ArrayList;
+
public class ProductsModel
{
/**
* Used for the GenericList example.
*/
- private var _productNames:Array = ["Widgets", "Thingys", "Sprockets", "Doohickies", "Weejets"];
- public function get productNames():Array
+ private var _productNames:ArrayList = new ArrayList(["Widgets", "Thingys", "Sprockets", "Doohickies", "Weejets"]);
+ public function get productNames():ArrayList
{
return _productNames;
}
+
+ private var _states:ArrayList = new ArrayList([
+ "Massachusetts", "Vermont", "New Hampshire", "Maine", "Rhode Island", "Conneticutt"]);
+
+ public function get states():ArrayList
+ {
+ return _states;
+ }
}
}
--
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <co...@royale.apache.org>'].