Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex(DataGrid),如何在鼠标移到行上时更改某些单元格的可见状态_Apache Flex_Datagrid - Fatal编程技术网

Apache flex Flex(DataGrid),如何在鼠标移到行上时更改某些单元格的可见状态

Apache flex Flex(DataGrid),如何在鼠标移到行上时更改某些单元格的可见状态,apache-flex,datagrid,Apache Flex,Datagrid,我有三列,最后一列的默认可见状态为false。我的问题是,当鼠标悬停在行的任何部分上时,如何更改特定单元格的可见状态 英语不是我的母语,所以如果我的问题不够清楚,请继续阅读 ------------------------------------------------ | column1 | column2 | column3 (invisible) | row1 | column1 | column2 | column3 (invisible) | row2 ------

我有三列,最后一列的默认可见状态为false。我的问题是,当鼠标悬停在行的任何部分上时,如何更改特定单元格的可见状态

英语不是我的母语,所以如果我的问题不够清楚,请继续阅读

------------------------------------------------ | column1 | column2 | column3 (invisible) | row1 | column1 | column2 | column3 (invisible) | row2 ------------------------------------------------ ------------------------------------------------ |第1列|第2列|第3列(不可见)|第1行 |第1列|第2列|第3列(不可见)|第2行 ------------------------------------------------
当鼠标悬停在第1行的任何列上时,如何显示单元格(第1行,第3列)。

以这种方式滚动第1列中的项目时,可以轻松切换整个列的可见性:

<mx:DataGrid dataProvider="{[{c1:'a1', c2:'b1', c3:'c1'}]}">
    <mx:columns>
        <mx:DataGridColumn headerText="Column 1" dataField="c1">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Label text="{listData.label}"
                        rollOver="DataGrid(owner).columns[2].visible = true"
                        rollOut="DataGrid(owner).columns[2].visible = false"
                    >
                        <mx:Script>
                            <![CDATA[
                                import mx.controls.DataGrid;
                            ]]>
                        </mx:Script>
                    </mx:Label>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="Column 2" dataField="c2" />
        <mx:DataGridColumn headerText="Column 3" dataField="c3" visible="false" />
</mx:DataGrid>

当然,您最好创建新类,而不是内联项呈现器

在第3列中显示唯一的渲染器非常棘手,因为如果整个列不可见,则不会创建该列的渲染器

我认为最好使用类似工具提示的解决方案,如下所示:

<mx:Script>
<![CDATA[
     import test.CellRenderer;
]]>
</mx:Script>
<mx:UIComponent id="textFlowContainer" width="100%" height="100%" />
<mx:DataGrid dataProvider="{[{c1:'a1', c2:'b1', c3:'c1'}]}">
    <mx:columns>
        <mx:DataGridColumn headerText="Column 1" dataField="c1" itemRenderer="{new ClassFactory(CellRenderer)}" />
        <mx:DataGridColumn headerText="Column 2" dataField="c2" itemRenderer="{new ClassFactory(CellRenderer)}" />
    </mx:columns>
</mx:DataGrid>

其中test.CellRenderer是:

<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" text="{listData.label}"
         rollOver="rollOverHandler()" rollOut="rollOutHandler(event)">
<mx:Script>
    <![CDATA[
        import mx.managers.PopUpManagerChildList;
        import mx.managers.PopUpManager;
        import mx.controls.Label;
        import mx.controls.DataGrid;

        private var popupLabel:Label;

        private function rollOverHandler ():void
        {
            popupLabel = new Label();
            popupLabel.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
            popupLabel.text = data.c3;
            PopUpManager.addPopUp(popupLabel, this, false, PopUpManagerChildList.PARENT);
            var p1:Point = new Point(0, this.y);
            p1 = localToGlobal(p1);
            var p2:Point = new Point(listData.owner.x+listData.owner.width, 0);
            p2 = listData.owner.parent.localToGlobal(p2);
            popupLabel.move(p2.x, p1.y);
        }

        private function rollOutHandler (event:MouseEvent):void
        {
            if (popupLabel && !popupLabel.hitTestPoint(event.stageX, event.stageY))
            {
                PopUpManager.removePopUp(popupLabel);
                popupLabel = null;
            }
        }
    ]]>
</mx:Script>
</mx:Label>


谢谢你,尼基塔!我不确定第二种方法,但第一种方法不是我想要的,我想要的只是显示一个单元格,而不是整个列。我将尝试第二种方法,看看是否有效。第二种方法仍然存在问题。事实上,我希望在某一行的末尾显示一些按钮,以便人们可以单击它。但当鼠标悬停在按钮上时,rollOutHandler会使其立即消失