Flex Repeater Horizontal Scrollbar - apache-flex

In my application I'm using a canvas and repeater inside HBox it is Dynamic,..now I want to keep a horizontal scrollbar for the same, I may display more than 50 canvas addresses inside that Hbox and repeater.
Here is my code:
<mx:HBox id="addrBox" x="42" y="161" width="1000%" styleName="ContextPanel" resizeEffect="resize" horizontalGap="5" height="0" paddingLeft="15">
<mx:Repeater id="rpt" maxWidth="1000" dataProvider="{ customerAddress }" >
<mx:Canvas height="243" width="283" id="addressCanv" cornerRadius="0" styleName="ContextPanel">
<mx:Label id="seq" text="{rpt.currentIndex+1 }" x="99" y="0"/>
<mx:TextInput id="address1" maxChars="50" change="address1_changeHandler(event)" text="{ rpt.currentItem.addressOne}" x="99" y="60"/>
<mx:TextInput id="address2" maxChars="50" change="address2_changeHandler(event)" text="{ rpt.currentItem.addressTwo}" x="99" y="90"/>
<mx:TextInput id="address3" maxChars="50" change="address3_changeHandler(event)" text="{ rpt.currentItem.addressThree}" x="99" y="120"/>
<mx:TextInput id="postalCd" restrict="[0-9]" maxChars="6" change="postalCd_changeHandler(event)" text="{ rpt.currentItem.postalCode}" x="99" y="150" width="167"/>
<mx:ComboBox id="cntryCdCmb" prompt="Select" change="cntryCdCmb_changeHandler(event)" selectedIndex="{ StaticDataHolder.countryList.getItemIndex(ASUtil.getValue(StaticDataHolder.countryList,rpt.currentItem.countryCode))}" dataProvider="{ StaticDataHolder.countryList }" x="99" y="180" width="167"/>
<mx:CheckBox id="primaryFlag" label="isPrimary" selected="{ (rpt.currentItem.primaryFlag == 0)?true:false }" change="primaryFlag_changeHandler(event)" x="19" y="210"/>
<mx:Label x="10" y="0" text="Seq No"/>
<mx:Label x="10" y="62" text="Address 1"/>
<mx:Label x="10" y="92" text="Address 2"/>
<mx:Label x="10" y="122" text="Address 3"/>
<mx:Label x="10" y="152" text="Postal Code"/>
<mx:Label x="10" y="182" text="Country Code"/>
<mx:Label x="10" y="29" text="Address Type"/>
<mx:ComboBox x="99" y="29" width="167" prompt="Select" change="addTypeCmb_changeHandler(event)" id="addTypeCmb" selectedIndex="{ StaticDataHolder.addressTypes.getItemIndex(ASUtil.getValue(StaticDataHolder.addressTypes,rpt.currentItem.addressType))}" dataProvider="{ StaticDataHolder.addressTypes }"></mx:ComboBox>
<mx:Label x="235" y="210" text="{ rpt.currentItem.primaryFlag}"/>
<mx:Image id="delAddr" x="258" y="3" height="21" width="17" source="images/delete2.png" maintainAspectRatio="true" click="delAddr_clickHandler(event)"/>
</mx:Canvas>
</mx:Repeater>
</mx:HBox>
Kindly give some idea for getting horizontal scroll bar for the Repeater.

Add one more attribute to your HBox that is horizontalScrollPolicy
<mx:HBox id="addrBox" x="42" y="161" width="100%" styleName="ContextPanel"
resizeEffect="resize" horizontalGap="5" height="0" paddingLeft="15" horizontalScrollPolicy="on">
You can set the values on, off and auto. By using auto
HScrollBar will be visible if contents does not fit in the given space.

<mx:HBox id="addrBox" x="42" y="161" width="100%" styleName="ContextPanel"
resizeEffect="resize" horizontalGap="5" height="0" paddingLeft="15" horizontalScrollPolicy="auto">
horizontalScrollPolicy auto gives the best result if it reduces from 50.

Related

Actionscript- How do I set a click handler on a tab in TabNavigator?

I want the TextArea under my second tab to update when the tab is clicked. However, it's only updating when I click on the TextArea or the container for that text area.
Flex:
<mx:Box paddingLeft="0" paddingRight="0" paddingBottom="0" paddingTop="0" width="100%" height="100%"
<mx:VBox id="vbxHTMLBody" width="100%" height="100%" horizontalScrollPolicy="off" horizontalAlign="center">
<mx:TabNavigator id = "tabNav" borderStyle="solid" width="100%" height="100%" creationPolicy="all">
<mx:VBox label="Tab1" width="100%" height="100%">
<mx:TextArea id="textArea1" paddingTop="25" paddingLeft="25" paddingRight="25" verticalScrollPolicy="on" focusThickness="0" borderThickness="0" borderStyle="none" editable="true" fontFamily="Arial" fontSize="14" width="100%" height="100%"/>
</mx:VBox>
<mx:VBox label="Tab2" width="100%" height="100%" click="updateTextArea2()">
<mx:TextArea id="textArea2" paddingTop="25" paddingLeft="25" paddingRight="25" verticalScrollPolicy="on" focusThickness="0" borderThickness="0" borderStyle="none" editable="true" fontFamily="Arial" fontSize="14" width="100%" height="100%"/>
</mx:VBox>
</mx:TabNavigator>
</mx:VBox>
</mx:Box>
ActionScript:
private function updateTextArea2(): void {
textArea2.htmlText = textArea1.text;
tabNav.validateNow();
textArea2.validateNow();
}
*I've also tried setting the click listener to the outer containers and that hasn't worked either.
I used change="updateTextArea2()" to listen for any changes made to the text area.
Call updateTextArea2()on change of the TabNavigator:
<mx:TabNavigator id="tabNav" change=updateTextArea2()">
instead from VBox change.

flex combobox dropdown textAlign issue

I have a combobox where the textAlign defaults to center. I tried setting it to texAlign="left", but the text is still centered.
<s:HGroup width="100%" height="90%" textAlign="left">
<s:VGroup width="45%" height="100%" textAlign="left">
<s:Label width="100%" fontSize="12" text="Company Name:" textAlign="left"
verticalAlign="middle"/>
<s:TextInput id="companyNameForm" width="100%"/>
<s:Label width="100%" fontSize="12" text="Industry:" textAlign="left"/>
<s:ComboBox id="companyIndustryForm" x="0" width="100%"
creationComplete="LoadIndustList(event)" labelField="IndustryEn"
selectedIndex="1"/>
<s:Label width="100%" fontSize="12" text="Contact Person:" textAlign="left"/>
<s:TextInput id="companyContactPersonForm" width="100%"/>
<s:Label width="100%" fontSize="12" text="Contact Phone:" textAlign="left"/>
<s:TextInput id="companyContactPhoneForm" width="100%"/>
<s:Label width="100%" fontSize="12" text="Created By:" textAlign="left"/>
<s:TextInput id="companyCreatedByForm" width="100%"/>
<s:Label width="100%" fontSize="12" text="Created Date" textAlign="left"/>
<s:TextInput id="companyCreatedDateForm" width="100%"/>
</s:VGroup>

How to align the formItems?

I'm trying to create a form, but i am having issues aligning the formItems.
This is mx:Form namespace. (xmlns:mx="http://www.adobe.com/2006/mxml")
does anyone have any suggestions on how to correct this. any help would be greatly appreciated.
<mx:VBox paddingLeft="0" height="100%">
<form:Form width="100%"
textAlign="left">
<mx:VBox>
<mx:HBox id="snapShotSelect">
<form:FormItem label="My Label Here"
includeInLayout="{model.formItemVisible}"
visible="{model.formItemVisible}"/>
<mx:VBox>
<form:FormItem includeInLayout="{model.formItemVisible}"
visible="{model.formItemVisible}">
<components:SageTextInput textAlign="left"/>
</form:FormItem>
<form:FormItem label=""
visible="{model.formItemVisible}"
includeInLayout="{model.formItemVisible}"/>
<form:FormItem visible="{model.formItemVisible}"
includeInLayout="{model.formItemVisible}">
<components:SageList id="snaps"
allowMultipleSelection="false"
width="200"
rowCount="5"/>
</form:FormItem>
</mx:VBox>
</mx:HBox>
<mx:HBox>
<form:FormItem label="My Label Here"
width="100%"
visible="{model.formItemVisible}"
includeInLayout="{model.formItemVisible}"/>
<form:FormItem label=""
width="100%">
<components:SageComboBox dataProvider="{model.generations}"
textAlign="left"
enabled="{model.generations.length > 0}"/>
</form:FormItem>
</mx:HBox>
<mx:HBox id="radioSelectGroup">
<form:FormItem label="">
<components:SageRadioButtonGroup id="rbGroup"
groupId="rbGroup"
labelPlacement="right"/>
</form:FormItem>
</mx:HBox>
<mx:HBox id="radioNew">
<form:FormItem>
<components:SageRadioButton id="radioCopy" value="{model.RADIO_CREATE}"
group="{rbGroup}"
labelPlacement="right"
width="250"
label="Radio Button 1" />
</form:FormItem>
<form:FormItem>
<components:SageTextInput textAlign="left"
enabled="{rbGroup.selectedValue == model.RADIO_CREATE}"/>
</form:FormItem>
</mx:HBox>
<mx:HBox id="radioExisting">
<form:FormItem>
<components:SageRadioButton id="radioNoCopy" value="{model.RADIO_USE_EXISTING}"
group="{rbGroup}"
labelPlacement="right"
width="250"
label="Radio Button 2"/>
</form:FormItem>
<mx:VBox>
<form:FormItem label=""
paddingBottom="0">
<components:SageTextInput textAlign="left"
enabled="{rbGroup.selectedValue == model.RADIO_USE_EXISTING}"/>
</form:FormItem>
<form:FormItem label=""
indentationLevel="0"
paddingTop="0">
<components:SageList allowMultipleSelection="false"
width="200"
rowCount="5"
enabled="{rbGroup.selectedValue == model.RADIO_USE_EXISTING}"/>
</form:FormItem>
</mx:VBox>
</mx:HBox>
</mx:VBox>
</form:Form>
</mx:VBox>
It Looks like this at the moment.
But i want it to look like this
Use the following code : Please adjust the width of spacer according to your alignment requirements. Also Dont miss out mentioning the width of every HBox and VBox inside the formItem. Here, I am using all mx components.
<mx:Form>
<mx:FormItem width="100%">
<mx:VBox id="ContainerVBox" width="100%">
<mx:HBox width="100%">
<mx:Label id="label1" text="my label here"/>
<mx:Spacer width="10%"/>
<mx:TextInput id="textInput1" text="This is text input 1"/>
</mx:HBox>
<mx:TextInput id="textInput2" text="This is text input 2"/>
</mx:VBox>
</mx:FormItem>
<mx:FormItem width="100%">
<mx:HBox width="100%">
<mx:Label id="label1" text="my label here"/>
<mx:Spacer width="10%"/>
<mx:ComboBox id="myComboBox"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem width="100%">
<mx:HBox width="100%">
<mx:RadioButton id="myRadioButton"/>
<mx:Text text="Radio Button 1"/>
<mx:Spacer width="10%"/>
<mx:TextInput id="textInput3"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem width="100%">
<mx:VBox width="100%">
<mx:HBox width="100%">
<mx:RadioButton id="myRadioButton"/>
<mx:Text text="Radio Button 2"/>
<mx:Spacer width="10%"/>
<mx:TextInput id="textInput4"/>
</mx:HBox>
<mx:TextInput id="textInput5" text="This is text input 5"/>
</mx:VBox>
</mx:FormItem>
</mx:Form>
</mx:VBox>

Positioning text in Flex

I want to display three different pieces of text in a line underneath a VBox so I've created a HBox and place the Text components in here:
<mx:HBox width="100%">
<mx:Text text="left" id="textLeft"/>
<mx:Text text="center" id="textCenter"/>
<mx:Text text="right" id="textRight"/>
</mx:HBox>
I want the text with id "textLeft" to be positioned on the very left on the HBox and textCenter to be in the center and textRight to be on the right...
Any solutions/pointers appreciated.
try
<mx:HBox width="100%">
<mx:Text text="left" id="textLeft"/>
<mx:Spacer width="100%" />
<mx:Text text="center" id="textCenter"/>
<mx:Spacer width="100%" />
<mx:Text text="right" id="textRight"/>
</mx:HBox>
or
<mx:HBox width="100%">
<mx:Text text="left" id="textLeft" textAlign="left" width="100%"/>
<mx:Text text="center" id="textCenter" textAlign="center" width="100%"/>
<mx:Text text="right" id="textRight" textAlign="right" width="100%"/>
</mx:HBox>
Personally I'd go with the top one
Thanks for your response. In the meantime I came up with this solution with help from a friend.
Using a grid:
<mx:Grid width="100%">
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="33%" height="100%" horizontalAlign="left">
<mx:Text text="left" id="textLeft"/>
</mx:GridItem>
<mx:GridItem width="33%" height="100%" horizontalAlign="center">
<mx:Text text="center" id="textCenter"/>
</mx:GridItem>
<mx:GridItem width="33%" height="100%" horizontalAlign="right">
<mx:Text text="right" id="textRight"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
However I do see that your solution is better for more things being added.

How to fix overlapping VBox children in a canvas?

I have multiple HBoxes inside a VBox inside a canvas like so:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:Canvas width="600" height="500">
<mx:VBox height="100%" left="10" right="10">
<mx:HBox width="100%" >
<mx:VBox width="48%" height="100%" horizontalAlign="left">
<mx:Label text="Label" />
</mx:VBox>
<mx:VBox width="48%" height="100%" horizontalAlign="left">
<mx:Label text="Label" />
<mx:HBox width="100%">
<mx:VBox width="48%">
<mx:Label text="Label" />
<mx:ComboBox />
</mx:VBox>
</mx:HBox>
</mx:VBox>
</mx:HBox>
<mx:VBox>
<mx:HBox>
<mx:Label text="Label" />
<mx:Label text="Label" />
</mx:HBox>
</mx:VBox>
<mx:HBox>
<mx:Label text="Label" />
<mx:ComboBox/>
</mx:HBox>
<mx:HBox>
<mx:VBox horizontalScrollPolicy="off" verticalScrollPolicy="off"
includeInLayout="false" >
<mx:Label text="Label" />
</mx:VBox>
<mx:VBox>
<mx:HBox horizontalScrollPolicy="off" verticalScrollPolicy="off"
includeInLayout="false"
>
<mx:VBox >
<mx:Label text="Text" />
<mx:ComboBox />
</mx:VBox>
<mx:VBox>
<mx:Label text="Label" />
<mx:ComboBox />
</mx:VBox>
</mx:HBox>
<mx:HBox horizontalScrollPolicy="off" verticalScrollPolicy="off"
includeInLayout="false"
>
<mx:VBox>
<mx:Label text="Label:"/>
<mx:ComboBox />
</mx:VBox>
<mx:VBox>
<mx:Label text="Label: "/>
<mx:ComboBox />
</mx:VBox>
</mx:HBox>
</mx:VBox>
</mx:HBox>
<mx:HBox >
<mx:Label text="Label:" />
<mx:CheckBox />
</mx:HBox>
</mx:VBox>
</mx:Canvas>
</mx:Application>
The last child in the VBox is overlapping with other components. How do you prevent children of a VBox in a Canvas from overlapping? How do you debug this situation?
I have tried the following:
Removing percent based sizing
IncludeInLayout = true
Sceenshot - Label and Checkbox Overlapping:
It's hard to say with the information provided, but the two questions that come to mind first are:
Is your VBox height greater than the sum of the heights of its children?
Have you set the verticalGap property on the VBox? verticalGap determines vertical spacing between children.
I just tried this (AIR app) and it looks alright to me.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas height="100%" width="100%"
borderStyle="solid"
backgroundColor="0x0000ff">
<mx:VBox height="100%" width="100%">
<mx:VBox backgroundColor="0xff0000" height="50%" width="100%">
<mx:HBox backgroundColor="0x000000" height="50%" width="50%"/>
<mx:HBox backgroundColor="0xffffff" height="50%" width="50%"/>
<mx:HBox backgroundColor="0x00ffff" height="50%" width="50%"/>
</mx:VBox>
<mx:HBox height="50%" width="100%"
backgroundColor="0xff0000" backgroundAlpha="0.5"
borderColor="0x000000" borderStyle="solid" borderThickness="1"/>
</mx:VBox>
</mx:Canvas>
</mx:WindowedApplication>
I resolved this by making the includeInLayout property of some of these components the same conditional used by their visible property.
Not sure what caused the issue though.

Resources