473,419 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Flex, Datagrids, rows & how to expand a row

16
Hi Everyone,

It's been a long time and I'm always appreciative of your help.

I'm working on a Datagrid at the component level in Flex.

I know that I can expand a row within the Datagrid by clicking on a row:

Expand|Select|Wrap|Line Numbers
  1.         private function onItemClick(e : ListEvent) : void
  2.         {
  3.             // setting these xml properties will automatically update the itemRenderers on the fly
  4.  
  5.             // expand the item clicked on
  6.             var selData : AssetInfo = e.itemRenderer.data as AssetInfo;
  7.             if (selData.expanded != true)
  8.                 selData.expanded = true;
  9.                }
  10.  
But when I try to accomplish the same thing with a mouse rollover, then I can no longer access ListEvent. Probably because rollOver has to deal with MouseEvent.

Nevertheless, I am able to see what the mouse is rolling over by way of trace:

Expand|Select|Wrap|Line Numbers
  1. I use the datagrid's property of rollOver="onCreationComplete()" to call the addEventListener
  2.  
  3.         private function onCreationComplete():void
  4.         {
  5.             //register for the mouse_over enter event
  6.             var myListener = addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);        
  7.         }
  8.  
  9.         private function onMouseOver(myListener):void
  10.         {
  11.             trace(myListener);
  12.         }
  13.  
  14.  
The question is, what can I do with the information being shown by the trace to expand one of the rows, as I do when I click on one of the rows.

Here's what is returned in the trace
Expand|Select|Wrap|Line Numbers
  1. [MouseEvent type="mouseOver" bubbles=true cancelable=false eventPhase=3 localX=12 localY=91 stageX=999 stageY=270 relatedObject=MyAppAir0.$MyApp.Shell114.HDividedBox115.$browser.$am.$tabnav.Canvas371.$assetList.ListBaseContentHolder376.DataGridItemRenderer1733 ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0 commandKey=false controlKey=false clickCount=0]
  2.  
  3.  
Thanx n advance
Oct 17 '08 #1
3 8612
kronus
16
I figured it out.

It was an epic “programming” journey over the weekend for me to figure out how to do the rollover on the items within the datagrid.

First, I found out that this lib(flexlib:VAccordion) cannot be used with Flex Builder 2, which is what I have at home. Then I found out that Flex Builder 3 can only run with Java 1.5, which is the version of Java that is allowed to install on 10.5 OS, which I am running 10.4. After that, I found out that the flexlib:VAccordion from the open source google code could not be implemented at the component level, which had me starting over from scratch. So, after battling with myself on how long it would take for me to get fired, I had to figure out that I had to use a listEvent, rather than a MouseEvent.

This morning, I discovered in an adobe tech manual, that itemRollOver, as opposed to RollOver, uses the ListEvent and not the MouseEvent. From there I was able to determine the rowIndex and the rest is datagrid history.

Expand|Select|Wrap|Line Numbers
  1. first, use the itemRollOver within the datagrid header
  2. <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml" 
  3.     width="100%" height="100%" 
  4.     verticalScrollPolicy="on"
  5.     paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0"
  6.     itemClick="onItemClick(event)"
  7.     variableRowHeight="true"
  8.     borderThickness="0"
  9.     showHeaders="false"
  10.     verticalGridLines="false" 
  11.     selectionColor="#EEEEEE"
  12.     rollOverColor="#D3D8DE"
  13.     textRollOverColor="#FFFFFF"
  14.     textSelectedColor="#000000"
  15.     color="#FFFFFF" 
  16.     styleName="listView"
  17.     itemRollOver="onMouseOver(event)"
  18. >
  19.  
  20. Then use this function to expand each row that the mouse rolls over:
  21.  
  22. import mx.events.DataGridEvent;
  23.  
  24. private function onMouseOver(event:ListEvent):void
  25. {
  26.     var myRow = event.rowIndex;
  27.     var data2 : ArrayCollection = this.dataProvider as ArrayCollection;
  28.  
  29.         for(var i:int = 0; i < data2.length; i++)
  30.         {
  31.             var dat2 : AssetInfo = data2[i] as AssetInfo;
  32.  
  33.             if (dat2 != data2[myRow] && dat2.expanded != false)
  34.                 dat2.expanded = false;
  35.         }
  36.         data2[myRow].expanded = true;
  37.         //trace(myRow);
  38. }
  39.  

And that's all there is to it :-)
Oct 20 '08 #2
kronus
16
Left something out that is pretty important to making this work:

expand is a state:
Expand|Select|Wrap|Line Numbers
  1.     <mx:states>
  2.         <mx:State name="expanded">
  3.             <!-- <mx:SetProperty name="height" value="196"/> -->
  4.             <mx:AddChild position="lastChild">
  5.  
  6.                 <mx:Canvas x="10" y="33" width="100%" height="100%" backgroundColor="#000000" id="$thumb" click="showPreview();" />
  7.  
  8.             </mx:AddChild>
  9.         </mx:State>
  10.     </mx:states>
  11.  
Also, this comes from an itemrenderer in the first column of the datagrid.

Expand|Select|Wrap|Line Numbers
  1. <mx:DataGridColumn id="assetDGC" itemRenderer="FirstColumn" headerText="Name" width="575" minWidth="160" sortable="true" sortCompareFunction="sortByName" />
  2.  
Dec 15 '08 #3
Kronus,
Is AssetInfo a separate class that has a member variable named expanded? How does the switching of the state occur? What does the itemrenderer for the datagrid column look like? Just a few questions after seeing this thread. Thanks for your reply in advance.

Thanks.
Jul 16 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: pavel.orehov | last post by:
Hi, I am using flex and bizon to write HTTP parser. I am passing well flex and bison tools but can't compile their output. ================= Flex file (http_parser.lpp) ============== %{...
2
by: Qumer Mumtaz | last post by:
H How to us MS Flex Grid in C#.I mean how to add columns and rows at run time and how to assign values to the columns and rows ? Any help in this regard will be appriciated Plz reply sooon............
2
by: melanieab | last post by:
Hi, Ok, I'm on my own in learning c# for work here and have come pretty far, but I'm confused by all the options available for datagrids. I have a private datagrid (dg), private dataset (ds), and...
3
by: Mark Wiewel | last post by:
hi all, i am a newbie in ASP.NET and i couldn't find the solution to this one: i have a form with three datagrids on it. i would like to align them vertically with a space between each grid of...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
5
by: ASP.NET explorer | last post by:
I have been asked to create some simple animation using Adobe Flash player in ASP.NET(C#) web application. While I am fairly well versed with ASP.NET C#, I absolutely have NO IDEA about how to...
10
by: Jules Winfield | last post by:
Guys, I've been designing applications for the financial services industry using MSFT technologies for many years (Win32 API, MFC, and now .NET WinForms). All applications are Internet-based,...
1
by: tshad | last post by:
I am trying to find the differences between handling of DataGrids in Windows Forms and Asp.Net. They are completely different in how you bind to them, get number of rows, look at columns and...
3
by: Tinkertim | last post by:
Hello to all, I've been using C for a long time however I'm about to take my first splash into making a parser. I have some interesting things to accomplish and I'm hoping to get some...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.