-1

这是我在 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

最后我想要这个输出但我没有得到..我认为有些东西是覆盖...给我建议..

Fanally 我的 DataGrid Visiable 完全像这样..

4

1 回答 1

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>
于 2013-01-04T11:17:21.137 回答