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.

layout: docpage title: Jewel VGroup description: The Jewel VGroup permalink: /component-sets/jewel/vgroup

< Jewel Components list

Jewel VGroup

Reference

Available since version 0.9.7.

ClassExtends
org.apache.royale.jewel.VGroup{:target=‘_blank’}org.apache.royale.jewel.supportClasses.group.AlignmentItemsGroupWithGap{:target=‘_blank’}

Note: This component is currently only available for JavaScript.

Overview

The Jewel VGroup class is a Group that lays out elements verticaly and provides some properties to allow more flexibility, like gap to define some spacing between items, and itemsHorizontalAlign and itemsVerticalAlign, to distribute elements in different ways along the horizontal and vertical axis.

Example of use

In MXML declare a VGroup like this:

<j:VGroup width="100%" height="300" gap="3" itemsVerticalAlign="itemsBottom">
	<j:Card width="50%" height="100">
		<j:Label text="vert bottom"/>
	</j:Card>
	<j:Card width="50%" height="100">
		<j:Label text="vert bottom"/>
	</j:Card>
</j:VGroup>

In ActionScript we can do the same in the following way.

var vg:VGroup = new VGroup();
// add a label to the VGroup
var label:Label = new Label();
label.text = "Some text";
vg.addElement(label);
// add the VGroup to the parent
parent.addElement(vg);

where parent is the container where the VGroup will be added.

Relevant Properties and Methods

Check the Reference of org.apache.royale.jewel.VGroup{:target=‘_blank’} for a more detailed list of properties and methods.

Properties

PROPERTYTypeDescription
currentStateStringThe name of the current state.
itemsExpandBooleanMake items resize to the fill all container space.
itemsHorizontalAlignStringDistribute all items horizontaly. Possible values are: itemsLeft, itemsCenter, itemsRight, itemsSpaceBetween, itemsSpaceAround
itemsVerticalAlignStringDistribute all items verticaly. Possible values are: itemsSameHeight, itemsCenter, itemsTop, itemsBottom
gapNumberAssigns variable gap in steps predefined in Jewel CSS.
numElementsintThe number of element children that can be laid out.
mxmlContentArrayThe array of childs for this group. Is the DefaultProperty.
statesArrayThe array of view states. These should be instances of org.apache.royale.states.State{:target=‘_blank’}
variableRowHeightBooleanSpecifies whether layout elements are allocated their preferred height.

Methods

MethodParametersDescription
addElementc(IChild), dispatchEvent(Boolean=true)Add a component to the parent.
addElementAtc(IChild), index(int), dispatchEvent(Boolean=true)Add a component to the parent at the specified index.
getElementIndexc(IChild)Gets the index of this subcomponent.
getElementAtindex(int)Get a component from the parent at specified index.
removeElementc(IChild), dispatchEvent(Boolean=true)Remove a component from the parent.

Relevant Events

The most important event is initComplete, which indicates that initialization of the group is complete.

It is needed when some action coded in a callback function needs to be triggered when the group is ready to use after initialization.

You can attach callback listeners to the initComplete event in MXML as follows:

<j:VGroup initComplete="initCompleteHandler(event)"/>

the initComplete event will use the initCompleteHandler callback function you provide in ActionScript:

<fx:Script>
    <![CDATA[      
        private function initCompleteHandler(event:Event):void {
            trace("VGroup is ready!");
        }
    ]]>
</fx:Script>

When the group is initialized the message “VGroup is ready!” appears in the console log.

In ActionScript we can add an event handler this way:

var vg:VGroup = new VGroup();
vg.addEventListener('initComplete', initCompleteHandler);
parent.addElement(vg);

Relevant Beads

Bead TypeImplementationDescription
GroupView{:target=‘_blank’}org.apache.royale.core.IBeadView{:target=‘_blank’}This is the default view bead.
VerticalLayout{:target=‘_blank’}org.apache.royale.core.IBeadLayout{:target=‘_blank’}This is the default layout bead.

Optional Beads

Bead TypeImplementationDescription
ContainerDataBinding{:target=‘_blank’}org.apache.royale.binding.DataBindingBase{:target=‘_blank’}Provide binding capabilities to the group.

More examples

Related controls

Other useful Jewel containers components are: