Should be easy but google couldn't give me a straight answer. I have an array. The fields in the array have underscores that I would like to remove e.g. "Column_1" to "Column 1". Does anyone know a good way to do this without looping through the whole array and rebuilding it anew? I didn't see any methods in the reference that would make this easy. thx
A:
Flex 3 has built in refactoring
Edit... I may have misunderstood..
If you want to format the data in the array just loop through it and use regex to remove the underscores... or you can modify your query which grabs the data (if it is populated from a query)
Chris Klepeis
2009-07-21 16:47:52
How do I access the field name of an array, not the data in the field, to change it? myArray[i].field_1 gets me data. How do I change "field_1" to "field 1"
mrjrdnthms
2009-07-21 17:14:36
+3
A:
Depending on where you are using this Array, you could use the labelFunction
to format the data before presenting it. It is present in Lists, DataGrids and Trees.
But you'd only need this if you have a very large data and wouldn't want to loop over all the records before showing them. A labelFunction
would "reprocess" the label everytime before it's presented.
leolobato
2009-07-21 16:52:51
If you don't want to rebuild the array, and you're only changing the contents of the array so that it looks nice for the end-user, then using a label function would be the way to go.
joshbuhler
2009-07-21 17:07:19
You guessed it, this was what I wanted even though its not what I asked for. thx
mrjrdnthms
2009-07-21 17:24:00