Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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');
            }
ASKER CERTIFIED SOLUTION
Avatar of Carnou
CarnouFlag of United States of America image

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

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers