开发者

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 e开发者_StackOverflowvent 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.

<?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 | www.infocepts.com ...........................................................................................

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜