简体   繁体   English

如何在flex中的数据网格上使用右键单击或更改function

[英]how to use the right click or change function on a datagrid in flex

i have a datagrid which contained several items,when i click one row, a panel will show,however, if i have already selected one row and then click some blank place, this panel will also show because there is already a selecteditem,which will be a problem.我有一个包含多个项目的数据网格,当我单击一行时,将显示一个面板,但是,如果我已经选择了一行然后单击某个空白位置,该面板也会显示,因为已经有一个选定的项目,这将成为问题。 Then i change this click event to change event, however, there will be another problem, which is if i click the same row, nothing will happend.然后我将这个点击事件更改为更改事件,但是,会有另一个问题,即如果我点击同一行,什么都不会发生。 so is there any better idea when i click a row, a panel shows and when i click the blank place, nothing happened.那么当我单击一行时,有没有更好的主意,一个面板显示,当我单击空白处时,什么也没发生。

You can use the global flag variable and set it to true when you click on item in data grid.当您单击数据网格中的项目时,您可以使用全局标志变量并将其设置为 true。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                      xmlns:mstr="http://web.microstrategy.com/visframe">
                      <mx:Script>
                        <![CDATA[

                        public var flag:Boolean = false;
                        public function showPanel():void
                        {
                            panel.visible = flag ? true : false;
                            flag=false;
                        }
                        ]]>

                      </mx:Script>

<mx:DataGrid id="dg" click="showPanel()" itemClick="flag=true;"
    dataProvider="{[{Name:'ABC', Age:'25'},{Name:'PQR', Age:'30'},{Name:'XYZ', Age:'20'}]}">
</mx:DataGrid>
<mx:Panel id="panel" visible="false" height="100" width="100"/>
</mx:Application>

Thanks and Regards,谢谢并恭祝安康,
........................................................................................... ..................................................... .........................................................
Pooja Kuber |普加库伯 | pkuber@infocepts.com | pkuber@infocepts.com | www.infocepts.com ........................................................................................... www.infocepts.com ................................... ..................................................

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM