如何在Flex DataGrid中实现向下钻取效果?

时间:2009-12-30 02:39:50

标签: flex datagrid

我希望Flex DataGrid实现向下钻取效果。 DataGrid的数据是从XML文件中获取的。

1 个答案:

答案 0 :(得分:0)

Datagrid应该是这样的:

<mx:DataGrid id="DataGridAnswers"
                 top="10" bottom="10" left="10" right="10"
                 >
        <mx:columns>
            <mx:DataGridColumn>
                <mx:itemRenderer>
                    <fx:Component>
                        <mx:LinkButton label="Посмотреть результат"
                                       click="linkbutton1_clickHandler(data.test_id, data.id)">
                            <fx:Script>
                                <![CDATA[
                                    import etc.NavigationEvent;
                                    protected function linkbutton1_clickHandler(testId:int, answerId:int):void
                                    {
                                        var navEvent:NavigationEvent = 
                                            new NavigationEvent(NavigationEvent.NAVIGATION_STRING, 
                                                NavigationEvent.REPORTS_SCREEN, true, true);
                                        navEvent.testId = testId;
                                        navEvent.answerId = answerId;
                                        dispatchEvent(navEvent);
                                    }
                                ]]>
                            </fx:Script>
                        </mx:LinkButton>
                    </fx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
        </mx:columns>
    </mx:DataGrid>

并在容器中处理此事件,如下所示:

protected function navigationHandler(event:NavigationEvent):void
            {
                // выбрать соответвтующий экран на главном меню
                mainMenu.selectScreen(event.screen);

                switch (event.screen)
                {
                    case NavigationEvent.LOGOUT:
                                                       ...
                        break;

                }

                // Переключить вью стек
                if (screenDic[event.screen] != null)
                    viewStack_main.selectedChild = screenDic[event.screen];
            }

加上将eventlistener添加到容器

initialize="this.addEventListener(NavigationEvent.NAVIGATION_STRING, navigationHandler)"