How to Select All checkboxes in Flex Item Renderer? - actionscript-3

I am stuck at a point where I need to select all check boxes of the Item Renderer.
I have a Select All button on whose click my all check boxes needs to get selected. Is it possible to do in Flex item renderer.
Below is my code for item renderer:
rowCount="2" columnCount="5" dragEnabled="false" dragMoveEnabled="false" height="100%" width="100%" verticalScrollPolicy="on" verticalScrollPosition="0" selectable="false">
<mx:itemRenderer>
<fx:Component>
<!--<mx:VBox height="100%" width="100%" verticalGap="0">-->
<mx:VBox width="175" height="200" verticalGap="0" verticalScrollPolicy="off" horizontalScrollPolicy="off" >
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.List;
import mx.core.FlexGlobals;
import mx.utils.ObjectUtil;
[Bindable]
public var productData:Array = new Array();
import mx.collections.ArrayCollection;
import mx.controls.listClasses.BaseListData;
private var _listData:BaseListData;
private var _tileList:List;
[Bindable("dataChange")]
public function get listData():BaseListData
{
return _listData;
}
public function set listData(value:BaseListData):void
{
_listData = value;
_tileList = value.owner as List;
}
override public function set data(value:Object):void
{
super.data = value;
checkFileToDownload.selected = value["isSelected"];
}
private function onChange(event:Event):void
{
data["isSelected"] = checkFileToDownload.selected;
FlexGlobals.topLevelApplication.checkFileToDownload(event);
}
/* protected function checkSelectedFile(event:MouseEvent):void
{
// TODO Auto-generated method stub
checkFileToDownload.selected = true;
FlexGlobals.topLevelApplication.generateDownloadFileArray("push",checkFileToDownload.name,checkFileToDownload.automationName);
outerDocument.downloadButtonStatus(event)
} */
]]>
</fx:Script>
<mx:HBox id="currentTileElement">
<s:CheckBox id="checkFileToDownload" name="{data.itemUrl}" automationName="{data.contentId}"
change="{onChange(event)}"
skinClass="com.skinClass.CustomCheckBoxSkin" click="{outerDocument.downloadButtonStatus(event)}"/>
<mx:TextArea wordWrap="true" fontWeight="bold" text="{data.title}" borderStyle="none" verticalScrollPolicy="off"
horizontalScrollPolicy="off" textAlign="left" editable="false"/>
</mx:HBox>
<mx:HBox>
<mx:Image source="{'/assets/'+data.contentId.substring(1, 2)+'.png'}" maintainAspectRatio="true"/>
<mx:Image id="tileListImageSource" width="150" height="75" maintainAspectRatio="false"
source="{data.localActualPath}"/>
</mx:HBox>
<!-- <mx:HBox horizontalGap="0">
<mx:Repeater id="itemCategory" dataProvider="{data.category.split('|')}">
<mx:Text textAlign="left" text="{itemCategory.currentItem}" color="#FF9900" fontWeight="bold" fontSize="9" />
</mx:Repeater>
</mx:HBox> -->
<mx:VBox horizontalGap="0" width="100%" verticalGap="0" paddingLeft="25">
<s:Spacer height="2"/>
<mx:TextArea text="{data.author.split('|')}" color="#FF9900" fontWeight="bold" chromeColor="white" height="40" editable="false" wordWrap="true" borderStyle="none" verticalScrollPolicy="on" horizontalScrollPolicy="off" textAlign="left"/>
<!-- <mx:Repeater id="authorCategory" dataProvider="{data.author.split('|')}">
<mx:Text textAlign="left" fontSize="11" fontSharpness="400" fontWeight="bold" color="#FF9900" text="{authorCategory.currentItem}"/>
</mx:Repeater> -->
<s:Spacer height="2"/>
<mx:Text fontSize="11" text="{data.publishedDate}"/>
<s:Spacer height="2"/>
<mx:HBox horizontalGap="0" verticalGap="0">
<mx:Text fontWeight="bold" fontSize="10" text="File Size: " paddingRight="0"/><mx:Text fontSize="10" color="red" paddingLeft="0" fontWeight="bold" text="{data.itemSize}MB"/>
</mx:HBox>
</mx:VBox>
</mx:VBox>
</fx:Component>
</mx:itemRenderer>
</mx:TileList>
Any help is appreciated.
Thanks,
Ankit Tanna.

You can affect all the checkboxes in your list by changing a property in the dataprovider;s objects and binding to that. Something like this in your click handler:
public function selectAllBtnClickHandler(e:MouseEvent):void {
if (selectAllBtn.selected) {
for each (var value:Object in checkboxList.dataProvider) {
value["isSelected"] = true;
}
}
}
Then change your checkbox declaration as follows:
<s:CheckBox id="checkFileToDownload" name="{data.itemUrl}" automationName="{data.contentId}"
change="{onChange(event)}" selected="{data.isSelected}"
skinClass="com.skinClass.CustomCheckBoxSkin" click="{outerDocument.downloadButtonStatus(event)}"/>

I want to clear the concept of Brian a bit , so that you can understand it better.
Here is an array collection i am using to populate the grid below
[Bindable] private var testArray:ArrayCollection = new ArrayCollection
(
[
{NAME:'Alan',DEPT:'CIS',ADDRESS:'dhaka',chk:0},
{NAME:'Jordan',DEPT:'CIS',ADDRESS:'dhaka',chk:1},
{NAME:'Simmi',DEPT:'CIS',ADDRESS:'dhaka',chk:0},
{NAME:'Alex',DEPT:'CIS',ADDRESS:'dhaka',chk:1},
{NAME:'Adams',DEPT:'CIS',ADDRESS:'dhaka',chk:0}
]
);
here goes the code of datagrid
<mx:DataGrid height="100%" width="100%" id="dataGrid" dataProvider="{testArray}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="NAME"/>
<mx:DataGridColumn headerText="Department" dataField="DEPT"/>
<mx:DataGridColumn headerText="Address" dataField="ADDRESS"/>
<mx:DataGridColumn headerText="Address" dataField="chk">
<mx:itemRenderer>
<fx:Component>
<mx:CheckBox selected="{data.chk==1?true:false}"/>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Check All" click="button1_clickHandler(event)"/>
Notice the item renderer which is a check box is looking on the value of "chk". You can make all the check boxes "CHECKED" by clicking "Check All" button. here is the "button1_clickHandler" function
protected function button1_clickHandler(event:MouseEvent):void
{
for(var i:int=0;i<testArray.length;i++)
{
testArray[i].chk = 1;
}
testArray.refresh();
}

Related

Flex/AS3 Change a variable

I have this code. I need change variable DiagnosIsWritten=true, when input_diagnos (TextInput) is written something. Can you help me to say all ways, how i can do it.
<fx:Script>
<![CDATA[
public var DiagnosIsWritten:Boolean;
</fx:Script>
<s:DataGrid id="examsDG" >
<s:columns>
<s:ArrayList>
<s:GridColumn editable="true" headerText=" width="156"
itemRenderer="modules.PatientCardModule.moduls.ToothModule.renderers.examsDG_BiteRenderer"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
examsDG_BiteRenderer.mxml :
<s:TextInput id="input_diagnos" text="test" width="100%" height="100%" />
Add a change listener:
either inline:
<s:TextInput id="input_diagnos" text="test" width="100%" height="100%" change="onChange(event)" />
or in as3:
input_diagnos.addEventListener(spark.events.TextOperationEvent.CHANGE, onChange);
protected function onChange(event:TextOperationEvent):void {
DiagnosIsWritten = true;
}

Flex update dataprovider after datagrid edited

I have a datagrid in flex with an itemrenderer and a dataprovider.
The problem is when I edit a datagrid, the provider don't get updated with the edited value.
Here is my datagrid:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" borderColor="#FFFFFF" cornerRadius="0">
<mx:Script>
<![CDATA[
import mx.core.Application;
[Bindable]
private var provider:ArrayCollection = new ArrayCollection([
{data:'1'},
{data:'2"}]);
]]>
</mx:Script>
<!-- Here is the data grid , the provider is groupeCollection, ihave set editable to true-->
<mx:DataGrid id="myGrid" width="100%" height="80%"
dataProvider="{provider}" x="0" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="data" >
<mx:itemRenderer>
<mx:Component>
<mx:NumericStepper minimum="1" maximum="10000" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
Now after editing the cell ( dataFiel="data" ) and printing the dataprovider, nothing changes in it.
Have not used Flex 3 since long but can you once check that whether ItemRenderer supports boolean property rendererIsEditor? If yes then set it to true then your renderer will also work as editor.
EDIT: I tried your code now and there seems to be some compiler error with delcaration of items in ArrayCollection. You seem to mix " and ' for items. I corrected it and now verified it in the below example which works. You can click the button to check before and after scenarios. I am pasting the complete code for your convenience just paste and run:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
protected function button1_clickHandler(event:MouseEvent):void
{
for(var i:int = 0; i<provider.length; i++) {
Alert.show(provider.getItemAt(i).data);
}
}
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" borderColor="#FFFFFF" cornerRadius="0">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.core.Application;
[Bindable]
private var provider:ArrayCollection = new ArrayCollection([
{data:'1'},
{data:'2'}]);
]]>
</mx:Script>
<!-- Here is the data grid , the provider is groupeCollection, ihave set editable to true-->
<mx:DataGrid id="myGrid" width="100%" height="80%"
dataProvider="{provider}" x="0" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="data" >
<mx:itemRenderer>
<mx:Component>
<mx:NumericStepper minimum="1" maximum="10000" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Button label="Check DP" click="button1_clickHandler(event)"/>
</mx:VBox>
</mx:Application>
You can use itemEditor instead of itemRenderer, itemRenderer only show your values if you want edit the data at runtime we have set value manually by using
data.propertyname = value;
Try this code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" borderColor="#FFFFFF" cornerRadius="0">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.core.Application;
[Bindable]
private var provider:ArrayCollection = new ArrayCollection([
{data:'1'},
{data:'2'}]);
]]>
</mx:Script>
<mx:VBox>
<!-- Here is the data grid , the provider is groupeCollection, ihave set editable to true-->
<mx:DataGrid id="myGrid" width="100%" height="80%"
dataProvider="{provider}" x="0" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="data" editorDataField="value">
<mx:itemEditor>
<mx:Component>
<mx:NumericStepper minimum="1" maximum="10000" />
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid width="100%" height="80%"
dataProvider="{provider}" x="0" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="data" >
<mx:itemRenderer>
<mx:Component>
<mx:NumericStepper minimum="1" maximum="10000" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Canvas>

How to add a click event to a item renderer button in a datagrid to delete the current row?

Hi i have a data grid with customer names in the i used an inline ItemRenderer to add a delete button now i want to add a click event to this button how can i do this? I added an addEventListner method in initApp() listening for a click it worked, But i want to use the click event from the button please help.
private function delItem(event:MouseEvent):void
{
if(event.target.label == "Delete User")
{
myArrayCollection.removeItemAt(myGrid.selectedIndex);
}
}
private function initApp():void
{
delButton.addEventListener(MouseEvent.CLICK,delItem);
}
Use something like this
<s:DataGrid id="dataGrid" left="5" right="5" top="5" bottom="5">
<s:ArrayCollection>
<s:DataItem key="1000" name="Abrasive" price="100.11" call="false"/>
<s:DataItem key="1001" name="Brush" price="110.01" call="true"/>
<s:DataItem key="1002" name="Clamp" price="120.02" call="false"/>
<s:DataItem key="1003" name="Drill" price="130.03" call="true"/>
<s:DataItem key="1004" name="Epoxy" price="140.04" call="false"/>
<s:DataItem key="1005" name="File" price="150.05" call="true"/>
<s:DataItem key="1006" name="Gouge" price="160.06" call="false"/>
<s:DataItem key="1007" name="Hook" price="170.07" call="true"/>
<s:DataItem key="1008" name="Ink" price="180.08" call="false"/>
<s:DataItem key="1009" name="Jack" price="190.09" call="true"/>
</s:ArrayCollection>
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="key"/>
<s:GridColumn dataField="name"/>
<s:GridColumn dataField="price"/>
<s:GridColumn dataField="call"/>
</s:ArrayList>
</s:columns>
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<fx:Script><![CDATA[
import mx.controls.Alert;
private function button1_clickHandler(event:MouseEvent):void {
Alert.show("Click on button: " + data[column.dataField]);
}
]]></fx:Script>
<s:Button label="{data[column.dataField]}" click="button1_clickHandler(event)"/>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:DataGrid>
Good practice is to define itemRenderer in separate file. Example:
<s:DataGrid id="dataGrid" left="5" right="5" top="5" bottom="5" itemRenderer="MyItemRenderer">...</s:DataGrid>
MyItemRenderer.mxml file located in src directory
<?xml version="1.0"?><s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script><![CDATA[
import mx.controls.Alert;
private function button1_clickHandler(event:MouseEvent):void {
Alert.show("Click on button: " + data[column.dataField]);
}
]]></fx:Script>
<s:Button label="{data[column.dataField]}" click="button1_clickHandler(event)"/></s:GridItemRenderer>
I hope it help you
<mx:DataGrid id="dg" dataProvider="{dp}">
<mx:columns>
<mx:DataGridColumn headerText="Serial No:" dataField="serial"/>
<mx:DataGridColumn headerText="Name:" dataField="name"/>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<mx:Box>
<mx:Script><![CDATA[
import mx.controls.Alert;
private function delItem(event:MouseEvent):void {
Alert.show("Click");
}
]]></mx:Script>
<mx:Button label="Delete User"
click="delItem(event)"/>
</mx:Box>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
Thank You for all your help I'm a beginner so took me some time to figure it out and here is how i solved it
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
[Bindable]
private var dp:ArrayCollection = new ArrayCollection
([
{serial:1,name:"maniteja"},
{serial:2,name:"laxmi"},
{serial:3,name:"bose"}
]);
public function gimmePop():void
{
dp.removeItemAt(dataGrid.selectedIndex);
}
]]>
</mx:Script>
<mx:DataGrid id="dataGrid" dataProvider="{dp}" rowCount="{dp.length}">
<mx:columns>
<mx:DataGridColumn dataField="serial" headerText="Serial:"/>
<mx:DataGridColumn dataField="name" headerText="Name:"/>
<mx:DataGridColumn id="deleteButton">
<mx:itemRenderer>
<mx:Component>
<mx:Button label="Delete User" click="outerDocument.gimmePop()"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>

Flex 4.6 : Make action for button in list

I'm beginner in Flex . my issue when to add button to list , i put the button in the itemrender but the action of navigator.pushView(views.Listde,ProblemsList.selectedItem);
make an error "Acess of undefined property navigator .
Code :
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import views.ButList;
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
navigator.pushView(views.Listde,ProblemsList.selectedItem);
}
]]>
</fx:Script>
<s:Group width="100%" height="100%" styleName="PCS.css">
<s:HGroup width="100%" height="100%" gap="2" verticalAlign="middle" horizontalAlign="center" paddingBottom="5" paddingLeft="5"
paddingRight="5" paddingTop="5">
<s:HGroup width="30%" height="100%" verticalAlign="middle" horizontalAlign="center">
<s:Label text="{data._AddedDate}" textAlign="left" verticalAlign="bottom" width="100%" height="100%"/>
</s:HGroup>
<s:VGroup width="50%" height="100%" verticalAlign="middle" horizontalAlign="right">
<s:BitmapImage source="images/{data.image}"/>
<s:TextArea editable="false" text="{data.description}"/>
<s:Label text="{data.price}"/>
<s:Button label="s" click="button1_clickHandler(event)"/>
</s:VGroup>
</s:HGroup>
</s:Group>
if any solution to resolve it by list or any component instead of list then i want button to navigate to view with the selected item and the change of the list to navigate to another view with the selected item also , then the change of list work success but the button action cannot defined with the navigator.
Thanks in advance for any help .
Create a custom event with data property and dispatch the event from item renderer or dispatch the list change event from the item renderer when clicking the button.
package myEvents
{
import flash.events.Event;
public class CustomEvent extends Event
{
public function CustomEvent(type:String,
data:Object=null) {
// Call the constructor of the superclass.
super(type);
// Set the new property.
this.data = data;
}
// Define static constant.
public static const MY_BUTTON_CLICKED:String = "myButtonClicked";
// Define a public variable to hold the state of the enable property.
public var data:Object;
// Override the inherited clone() method.
override public function clone():Event {
return new CustomEvent(type, data);
}
}
}
MyItemRenderer.mxml
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import views.ButList;
protected function button1_clickHandler(event:MouseEvent):void
{
// dispatch a custom
(this.owner as List).dispatchEvent(new CustomEvent(CustomEvent.MY_BUTTON_CLICKED, data));
//navigator.pushView(views.Listde,ProblemsList.selectedItem);
}
]]>
</fx:Script>
<s:Group width="100%" height="100%" styleName="PCS.css">
<s:HGroup width="100%" height="100%" gap="2" verticalAlign="middle" horizontalAlign="center" paddingBottom="5" paddingLeft="5"
paddingRight="5" paddingTop="5">
<s:HGroup width="30%" height="100%" verticalAlign="middle" horizontalAlign="center">
<s:Label text="{data._AddedDate}" textAlign="left" verticalAlign="bottom" width="100%" height="100%"/>
</s:HGroup>
<s:VGroup width="50%" height="100%" verticalAlign="middle" horizontalAlign="right">
<s:BitmapImage source="images/{data.image}"/>
<s:TextArea editable="false" text="{data.description}"/>
<s:Label text="{data.price}"/>
<s:Button label="s" click="button1_clickHandler(event)"/>
</s:VGroup>
</s:HGroup>
</s:Group>
Your view class
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="MY View">
<s:layout>
<s:VerticalLayout paddingTop="10"/>
</s:layout>
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
private function onListCreationComplete_Handler():void
{
myList.addEventListener(CustomEvent.MY_BUTTON_CLICKED, onItemRendererButtonClicked);
}
protected function onItemRendererButtonClicked(event:CustomEvent):void {
var data:Object = event.data;
navigator.pushView(views.Listde,data);//myList.selectedItem
}
]]>
</fx:Script>
<s:Label text="Select an view"/>
<s:List id="myList"
width="100%" height="100%"
labelField="firstName" itemRenderer="MyItemRenderer"
change="myList_changeHandler(event)" creationComplete="onListCreationComplete_Handler()">
<s:ArrayCollection>
<fx:Object description="Fruits" image="assets/icons/1.png" _AddedDate="15/05/14" price="154"/>
<fx:Object description="New Item" image="assets/icons/2.png" _AddedDate="15/05/14" price="154"/>
<fx:Object description="Doll" image="assets/icons/3.png" _AddedDate="15/05/14" price="154"/>
</s:ArrayCollection>
</s:List>
</s:View>
I hope this might help u. There are tons of examples out there for list and item renderer for mobile.
Based on your ItemRenderer, you can simply listen to the IndexChangeEvent in your View. In this case, you don't need a separate button at all - the whole ItemRenderer can act as the button.
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="MY View">
<s:layout>
<s:VerticalLayout paddingTop="10"/>
</s:layout>
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
import views.ButList;
protected function myList_changeHandler(event:IndexChangeEvent):void {
navigator.pushView(views.Listde,myList.selectedItem);
}
]]>
</fx:Script>
<s:Label text="Select an view"/>
<s:List id="myList"
width="100%" height="100%"
labelField="firstName" itemRenderer="MyItemRenderer"
change="myList_changeHandler(event)">
<s:ArrayCollection>
<fx:Object description="Fruits" image="assets/icons/1.png" _AddedDate="15/05/14" price="154"/>
<fx:Object description="New Item" image="assets/icons/2.png" _AddedDate="15/05/14" price="154"/>
<fx:Object description="Doll" image="assets/icons/3.png" _AddedDate="15/05/14" price="154"/>
</s:ArrayCollection>
</s:List>
</s:View>

How to handle DataGrid Data Provider value in Flex?

This is my DataGrid Code in Flex Application But it is Giving Wrong Output..
<mx:DataGrid id="userListDataGrid" x="60" y="40" width="520" height="148" dataProvider="{schedule}">
<mx:columns>
<mx:DataGridColumn dataField="courseDate" headerText="Date"/>
<mx:DataGridColumn id="usertype" dataField="userType" headerText="User Type"/>
<mx:DataGridColumn id="button1" headerText="Reminder">
<mx:itemRenderer>
<mx:Component>
<mx:HBox dataChange="join_changeHandler()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import valueObjects.CalendarVO;
[Bindable]public var labelString:String = null;
public var calendar:CalendarVO;
protected function join_changeHandler():void
{
for each(var cal:Object in outerDocument.schedule)
{
calendar = new CalendarVO();//Hear CalendarVO has Enum in java(HOST,ATTENDEE)only
calendar.userType = cal.userType;
//Alert.show(calendar.userType.toString());
if(calendar.userType.toString() == "HOST")
{
join.visible = true;
start.visible = false;
}
else
{
join.visible = false;
start.visible = true;
}
}
}
]]>
</mx:Script>
<mx:Button id="join" label="Join" borderColor="#5d93b9" color="#04becf">
</mx:Button>
<mx:Button id="start" label="Start" borderColor="#5d93b9" color="#04becf"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
Actually my intention is UserType value
Host----Start Button
Attendee----JOin Button will be visiable
Finally i want this Out put But i'm not Getting .. i think some thing is Override...give me Suggestion..
Finally i got Result hear is my Code..
<mx:DataGrid id="userListDataGrid" x="60" y="40" width="520" height="148" dataProvider="{schedule}">
<mx:columns>
<mx:DataGridColumn dataField="courseDate" headerText="Date"/>
<mx:DataGridColumn dataField="courseName" headerText="Course Name"/>
<mx:DataGridColumn id="usertype" dataField="userType" headerText="User Type"/>
<mx:DataGridColumn headerText="Reminder">
<mx:itemRenderer>
<mx:Component>
<mx:HBox dataChange="join_changeHandler()">
<mx:Script>
<![CDATA[
protected function join_changeHandler():void
{
if(join.label == 'HOST')
join.label="Start";
else
join.label="Join";
}
]]>
</mx:Script>
<mx:Button id="join" label="{data.userType}" borderColor="#5d93b9" color="#04becf"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>