troubleshooting Question

Convert Flex Datagrid results into a string

Avatar of piyushdabomb
piyushdabomb asked on
Adobe FlashApache Flex
2 Comments1 Solution580 ViewsLast Modified:
Hey,

I've spent WAYY too many hours trying to figure this out, and about to pull my hair out. I have a Flex Datagrid that I'm trying to convert into a SIMPLE string. My function is the following:

A couple problems:

Problem #1 - When the datagrid converts to a string, the order of the items in my string are arranged in an adhoc manner. So for example if the first row of the datagrid contains the <First Name> , followed by the <Last Name>, followed by the <Age>, the iteration over obj2 doesn't stay in the <First Name> <Last Name> <Age> order...the order always spits out randomly! What is really interesting is that on different computers, the order changes, but on the same computer, the order doesn't change. Is there a better way to save the datagrid results to a string?

The second problem - When you iterate over obj2, there is this wierd binary string that comes out like 078285D5-7022-17BC-4EE3-98E93E8696A4

What sucks is that now that "078285D5-7022-17BC-4EE3-98E93E8696A4" is also added into my string. You'll notice that I've tried taking it out in my code but, it doesn't work all the time.



private var file:FileReference = new FileReference();
private var myString:String = new String
private var sTemp:String = new String
private var inti:Number
private var intCountDash:Number
			
private function ExporttoCSV():void{
myString = "Cost, Attribute, Change, PV, Level, ROI\r\n"
for each( var obj:Object in myData )
{
for each( var obj2:Object in obj )
{
intCountDash = 0;
var encr_int: Number=0;
trace(String(obj2));
for (inti=0; inti < String( obj2 ).length; inti++) 
{	
if(String( obj2 ).charAt(inti) == '-') 
	{
         						intCountDash = intCountDash + 1;
         					}
      					}
	  					if (sTemp != "")
	  					{		
							if (intCountDash !=4)
							{
								if (String( obj2 ) == "&#8593;")
								{
									sTemp += "," + "Increased from Current";
								}
								if (String( obj2 ) == "&#8595;")
								{
									sTemp += "," + "Decreased from Current";
								}
								if (String( obj2 ) == "&#8596;")
								{
									sTemp += "," + "No Change";
								}
								if ((String( obj2 ) != "&#8593;") && (String( obj2 ) != "&#8595;") && (String( obj2 ) != "&#8596;"))
								{
									sTemp += "," + String( obj2 )	
								}
							}
						}
						else
						{
							sTemp = String( obj2 )
						}
					}
					myString += sTemp + "\r\n";
					trace(myString);
					sTemp = "";
				}
				

                        //var test:String = "Hello World, By World"
                        file.save(myString,'Report.txt');
            }

Open in new window

ASKER CERTIFIED SOLUTION
Carnou

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros