zealouse
03-05-2009, 02:15 AM
The code works but.... only if INDEX 0 has all of the column labels :o
what do I do if I dont know the column names in advance?
Example:
Index 0
Column: A B
Value: 1 1
Index 1 !!! this will not work since C wasnt in Index 0 :(
Column: A B C
Value: 2 2 2
//declare vars
///data dpovider array
var dp:Array = new Array();
var return_format:Array = new Array();
///split array
var formated:Array;
///onject to store values
var Obj:Object = new Object();
//value string
var myInfo:String = 'A1 B1'+('\r\n')+'A2 B2 C2';
//split at ' ' new array
return_format = myInfo.split('\r\n');
///format between nextline
for (var i = 0; i<return_format.length; i++) {
//split at ' ' new array
formated = return_format[i].split(' ');
//clear object
Obj = {};
///Pull out each letter for 'Type' and set value 'types:Value'
for (var j = 0; j<formated.length; j++) {
///Type
Types = formated[j].slice(0, 1);
//trace(Types)
//value
Value = formated[j].slice(1, formated[j].length);
//Type:value to objects
Obj[Types] = Value;
}
///push object
dp.push(Obj);
}
//!!!!have to have the column!!!
dp.unshift({A:'', B:'', C:''});
///send to dataprovider
Data_Grid.dataProvider = dp;
what do I do if I dont know the column names in advance?
Example:
Index 0
Column: A B
Value: 1 1
Index 1 !!! this will not work since C wasnt in Index 0 :(
Column: A B C
Value: 2 2 2
//declare vars
///data dpovider array
var dp:Array = new Array();
var return_format:Array = new Array();
///split array
var formated:Array;
///onject to store values
var Obj:Object = new Object();
//value string
var myInfo:String = 'A1 B1'+('\r\n')+'A2 B2 C2';
//split at ' ' new array
return_format = myInfo.split('\r\n');
///format between nextline
for (var i = 0; i<return_format.length; i++) {
//split at ' ' new array
formated = return_format[i].split(' ');
//clear object
Obj = {};
///Pull out each letter for 'Type' and set value 'types:Value'
for (var j = 0; j<formated.length; j++) {
///Type
Types = formated[j].slice(0, 1);
//trace(Types)
//value
Value = formated[j].slice(1, formated[j].length);
//Type:value to objects
Obj[Types] = Value;
}
///push object
dp.push(Obj);
}
//!!!!have to have the column!!!
dp.unshift({A:'', B:'', C:''});
///send to dataprovider
Data_Grid.dataProvider = dp;