这是我在Flex应用程序中使用的DataGrid代码,但它提供了错误的输出..
<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>
其实我的意图是UserType值
Host----Start Button
Attendee----JOin Button will be visiable
最后我想要这个Out put但是我没有得到......我认为有些事情是Override ...给我建议..
答案 0 :(得分:0)
最后我得到了结果听到的是我的代码..
<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>