Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-21-2009, 10:46 PM   #1
rattleheadmegafan
Senior Member
 
Join Date: Mar 2008
Posts: 123
Default Datagrid question

I have an XML structure which is like this:

Code:
<details>
   <personal>
       <name>name</name>
       <phone>1111111111</phone>
   </personal>
   <tag1>
      <tag2>eee</tag2>
      <tag3>ffff</tag3>
      <rtag1>
          <rtag2>aa</rtag2>
          <rtag3>bb</rtag3>
      </rtag1>
      <rtag1>
          <rtag2>cc</rtag2>
          <rtag3>dd</rtag3>
      </rtag1>
   </tag1>
</details>
Now I want to be able to display the following in a datagrid,
name, phone, tag2, tag3 and multiple rtag2 and rtag3's

How do I do it?

Is there a solution, an alternate solution?

TIA!
rattleheadmegafan is offline   Reply With Quote
Old 08-24-2009, 05:39 PM   #2
camden_kid
Registered User
 
Join Date: Jul 2009
Location: London
Posts: 24
Default The livedocs example should help you out...

http://livedocs.adobe.com/flex/3/lan...xamplesSummary
camden_kid is offline   Reply With Quote
Old 08-26-2009, 04:17 AM   #3
rattleheadmegafan
Senior Member
 
Join Date: Mar 2008
Posts: 123
Default

Thanks Camden kid, that didn't help at all.
rattleheadmegafan is offline   Reply With Quote
Old 08-26-2009, 06:17 AM   #4
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Erm... maybe use Tree or AdvancedDataGrid (this is a component that isn't a part of free SDK)? Becuase DataGrid is intended for display of 2D tables... I believe you can also make a special item-renderer that will display the data you need in some more appropriate way, but I would really consider using another component or organizing your data differently.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 08-26-2009, 03:03 PM   #5
rattleheadmegafan
Senior Member
 
Join Date: Mar 2008
Posts: 123
Default

Thanks wvxvw!
rattleheadmegafan is offline   Reply With Quote
Old 08-29-2009, 08:34 AM   #6
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

i think labelFunction property of DataGridColumn is what u need....
and u can use a List as the itemRenderer for the column displaying rtag2 etc...
__________________
Blog
amarghosh is offline   Reply With Quote
Old 08-29-2009, 11:30 AM   #7
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

i am not able to post the code here... Has anyone else had this problem?
__________________
Blog

Last edited by amarghosh; 08-29-2009 at 11:45 AM. Reason: edited my stupid grammer :)
amarghosh is offline   Reply With Quote
Old 08-29-2009, 11:33 AM   #8
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

ActionScript Code:
<mx:DataGrid dataProvider="{list}">     <mx:columns>         <mx:DataGridColumn headerText="name" labelFunction="dataFunctionName"/>         <mx:DataGridColumn headerText="phone" labelFunction="dataFunctionPhone"/>         <mx:DataGridColumn headerText="tag2" labelFunction="dataFunctionTag2"/>         <mx:DataGridColumn headerText="tag3" labelFunction="dataFunctionTag3"/>         <mx:DataGridColumn headerText="rtag2">             <mx:itemRenderer>                 <mx:Component>                     <mx:List rowCount="{data.tag1.rtag1.rtag2.length()}"                         dataProvider="{data.tag1.rtag1.rtag2}"/>                 </mx:Component>             </mx:itemRenderer>         </mx:DataGridColumn>     </mx:columns> </mx:DataGrid>
__________________
Blog
amarghosh is offline   Reply With Quote
Old 08-29-2009, 11:34 AM   #9
amarghosh
unRegistered User
 
amarghosh's Avatar
 
Join Date: Feb 2008
Location: Bangalore
Posts: 817
Default

ActionScript Code:
public function dataFunctionName(item:Object, column:DataGridColumn):String {     return item.personal.name; } public function dataFunctionPhone(item:Object, column:DataGridColumn):String {     return item.personal.phone; } public function dataFunctionTag2(item:Object, column:DataGridColumn):String {     return item.tag1.tag2; } public function dataFunctionTag3(item:Object, column:DataGridColumn):String {     return item.tag1.tag3; }

EDIT: Apparently the issue was related to the size of the post... was trying to post this AS code and the mxml in the previous post together with no luck.
__________________
Blog
amarghosh is offline   Reply With Quote
Old 08-29-2009, 11:47 PM   #10
rattleheadmegafan
Senior Member
 
Join Date: Mar 2008
Posts: 123
Default

Thanks Amar, I will try that out.
rattleheadmegafan is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:00 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.