473,568 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flex xmllist to datagrid into a single row

16 New Member
I have made a lot of datagrids work in my time, but I seem to be missing something.

I'm receiving an xmllist and all I'm trying to do is set the dataprovider. It should be straight forward, but it's placing all the children of '<userName>some Name</userName>' into a single row.

Here's the xmllist that I'm receiving:
Expand|Select|Wrap|Line Numbers
  1. <users><userName>rob</userName>
  2. <userName>testd3</userName>
  3. <userName>mickey</userName>
  4. <userName>john</userName>
  5. <userName>kip</userName>
  6. <userName>pauly</userName></users>
  7.  
Here's the AS3 code receiving the xmllist and setting a provider:
Expand|Select|Wrap|Line Numbers
  1.             private function gotUsersOfGroups(x:XMLList):void
  2.             {
  3.                 var myString:String = '<users>';
  4.                 myString += x.children().child("userName");
  5.                 myString += '</users>';
  6.                 trace(myString);
  7.                 var myXml:XML = new XML(myString);
  8.  
  9.                 myUserList.dataProvider = myXml;
  10.             }            
  11.  
Pretty simple, right? I've tried myXml.userName, myXml.children( ), myXml.children. child("userName ") and nothing seems to work.

What am I missing?

As usual, thanx n advance
Oct 24 '08 #1
2 9999
kronus
16 New Member
I figured it out and it was something simple. I had to send my XML to an XMLListCollecti on. I renamed the variables so that the code could be easy to follow. And I had to take out the Datagrid columns section of the mxml

Expand|Select|Wrap|Line Numbers
  1.             private function gotUsersOfGroups(x:XMLList):void
  2.             {
  3.                 var xmlListString:String = '<users>';
  4.                 xmlListString += x.children().child("userName");
  5.                 xmlListString += '</users>';
  6.                 var convertUserStringToXml:XML = new XML(xmlListString);
  7.                 var usersOfGroupsXmlListCol:XMLListCollection = new XMLListCollection(convertUserStringToXml.userName);
  8.  
  9.  
  10.                 myUserList.dataProvider = usersOfGroupsXmlListCol;
  11.                 trace(usersOfGroupsXmlListCol);
  12.             }
  13.  
  14.             <mx:DataGrid id="myUserList" height="100%" width="65%" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" styleName="blueContainer1" backgroundColor="#2C4054" color="#FFFFFF" />
  15.  
But now, I cannot name the column header. How do I do that without bringing back the datagrid columns?

Thanx n advance
Oct 24 '08 #2
kronus
16 New Member
I was able to use the labelFunction for the datagridcolumn to populate the datagridcolumn, along with the use of the headerText to give my column a header.

First, the new mxml
Expand|Select|Wrap|Line Numbers
  1.         <mx:DataGrid id="myUserList" height="100%" width="65%" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" styleName="blueContainer1" backgroundColor="#2C4054" color="#FFFFFF">
  2.             <mx:columns>
  3.                 <mx:DataGridColumn headerText="Users" labelFunction="usersOfGroupLabelFunction" />
  4.             </mx:columns>
  5.  
  6.         </mx:DataGrid>
  7.  
And the two functions that make it possible for me to have my cake and eat it too:
Expand|Select|Wrap|Line Numbers
  1.             private function gotUsersOfGroups(x:XMLList):void
  2.             {
  3.                 var xmlListString:String = '<Users>';
  4.                 xmlListString += x.children().child("userName");
  5.                 xmlListString += '</Users>';
  6.                 trace(xmlListString);
  7.                 var convertUserStringToXml:XMLList = new XMLList(xmlListString);
  8.                 var usersOfGroupsXmlListCol:XMLListCollection = new XMLListCollection(convertUserStringToXml);
  9.  
  10.                 var sortA:Sort = new Sort();
  11.                 sortA.fields= [new SortField(null, true)];
  12.                 usersOfGroupsXmlListCol.sort=sortA;
  13.                 usersOfGroupsXmlListCol.refresh();
  14.  
  15.                 myUserList.dataProvider = usersOfGroupsXmlListCol.child("userName").valueOf();
  16.                 myUserList.validateNow();
  17.             }
  18.  
  19.             private function usersOfGroupLabelFunction(item:Object, uogDataGridCol:DataGridColumn):String
  20.             {
  21.                 return item.text();
  22.             }
  23.  
Two things:
1) Since this particular xml data was different in construct than all the other xml data that I was retrieving, then I had to treat it differently. Namely in that the other xml data had <sometag name="something " /> but this one was <sometag>someth ing</sometag> and apparently my Flex 3 no longer likes item.valueOf but item.text worked just fine. Go figure?
2) I threw in a Sort function that I found somewhere on the net while trying to figure this out and I knew that if the sort function was working, then I had a true XMLListCollecti on.

Thanx 4 giving me a sounding board
Oct 28 '08 #3

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

Similar topics

4
3604
by: Peter Kleiweg | last post by:
Hi, I am looking for a Python equivalent of Flex. After some browsing, it seems that Plex is my best bet, but I would like to hear suggestions before I dive in. I have been using Flex a lot in combination with C programming. I never use Yacc (or Bison), though Flex and Yacc are supposed to be used together. But I found Yacc too...
2
6573
by: olig9 | last post by:
Hello, is there a way to feed an ifstream to a parser generated with flex and bison? I could see that flex wants a FILE* for reading, but I only have an ifstream (actually and ifstream*) for input. It seems that flex++ can use an ifstream; but how does the generated lexer then work with bison? Or is there a (portable) way to get a FILE*...
2
13994
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......... Thanx
9
10741
by: Vincent | last post by:
I am trying to create a function that is called on the Flex Grid's MouseDown event. However, this event is not listed in the properties for this object. I tried to manually create the prototype for this event as: Private Sub flGrid_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) End Sub This only gives me an...
5
5940
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 say "Hello World" in a Flash enabled web page rendered via ASP.NET. Can any one let me get started? ---
10
6697
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, with a "thick client" which makes calls to my grid of servers via a socket or remoting connection. Customers are pleased with my work but it seems...
3
3525
by: Tarik Monem | last post by:
Hi Everyone, Still a newbie with FLEX, and I've passed arrays using AJAX to FLEX before, but I've never passed links to FLEX. Basically, this is the OUTPUT, which I wanted, but I'm given an error of "illegal character," from the JavaScript console: Error: illegal character Source Code:
3
8621
by: kronus | last post by:
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: private function onItemClick(e : ListEvent) : void
0
2290
by: bhappy | last post by:
Hi, I am using Flex 3.0 version. Can anyboday have any idea about showing hand symbol on mouseover of any cell in datagrid? Please provide me any sample code or links. Thanks in Advance, Aswath.
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.