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: -
<users><userName>rob</userName>
-
<userName>testd3</userName>
-
<userName>mickey</userName>
-
<userName>john</userName>
-
<userName>kip</userName>
-
<userName>pauly</userName></users>
-
Here's the AS3 code receiving the xmllist and setting a provider: -
private function gotUsersOfGroups(x:XMLList):void
-
{
-
var myString:String = '<users>';
-
myString += x.children().child("userName");
-
myString += '</users>';
-
trace(myString);
-
var myXml:XML = new XML(myString);
-
-
myUserList.dataProvider = myXml;
-
}
-
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
2 9999
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 -
private function gotUsersOfGroups(x:XMLList):void
-
{
-
var xmlListString:String = '<users>';
-
xmlListString += x.children().child("userName");
-
xmlListString += '</users>';
-
var convertUserStringToXml:XML = new XML(xmlListString);
-
var usersOfGroupsXmlListCol:XMLListCollection = new XMLListCollection(convertUserStringToXml.userName);
-
-
-
myUserList.dataProvider = usersOfGroupsXmlListCol;
-
trace(usersOfGroupsXmlListCol);
-
}
-
-
<mx:DataGrid id="myUserList" height="100%" width="65%" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" styleName="blueContainer1" backgroundColor="#2C4054" color="#FFFFFF" />
-
But now, I cannot name the column header. How do I do that without bringing back the datagrid columns?
Thanx n advance
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 -
<mx:DataGrid id="myUserList" height="100%" width="65%" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" styleName="blueContainer1" backgroundColor="#2C4054" color="#FFFFFF">
-
<mx:columns>
-
<mx:DataGridColumn headerText="Users" labelFunction="usersOfGroupLabelFunction" />
-
</mx:columns>
-
-
</mx:DataGrid>
-
And the two functions that make it possible for me to have my cake and eat it too: -
private function gotUsersOfGroups(x:XMLList):void
-
{
-
var xmlListString:String = '<Users>';
-
xmlListString += x.children().child("userName");
-
xmlListString += '</Users>';
-
trace(xmlListString);
-
var convertUserStringToXml:XMLList = new XMLList(xmlListString);
-
var usersOfGroupsXmlListCol:XMLListCollection = new XMLListCollection(convertUserStringToXml);
-
-
var sortA:Sort = new Sort();
-
sortA.fields= [new SortField(null, true)];
-
usersOfGroupsXmlListCol.sort=sortA;
-
usersOfGroupsXmlListCol.refresh();
-
-
myUserList.dataProvider = usersOfGroupsXmlListCol.child("userName").valueOf();
-
myUserList.validateNow();
-
}
-
-
private function usersOfGroupLabelFunction(item:Object, uogDataGridCol:DataGridColumn):String
-
{
-
return item.text();
-
}
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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*...
|
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
|
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...
|
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?
---
| |
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...
|
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:
|
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
|
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.
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |