I'm dynamically adding rows and they don't seem to go under the proper column. I have all of my headers in 'he开发者_Go百科aderArray' and the data i need to add is in the string 'item'.
//create an item to work with
var chartItem:Object = new Object();
for( var j:int = 0; j < columnResult.length ; j++ )
{
var item:String = removeformat(removetd(columnResult[j]));
//grab the header (this is which column the value will be added
var head:String = headerArray[j];
//set the value to header (pair)
chartItem[head] = item;
}
//add the chartItem (row) to the main collection
arr.addItem(chartItem);
tableCollection = arr;
It's getting all the headers properly and setting the chartItem (from inspection with debugger). When it gets to a row (building from html) where there is an item that only has values for some of the columns, it doesn't add the information under the right column, it just goes from left to right and adds it in the next one.
The behaviour is kind of strange because the chartItem clearly has the right header value and corresponding item value in it, but like I said they don't end up under the right column.
tableCollection gets set as the dataprovider for the grid later (not modified since)
var chartItem:Object = new Object();
var span:int = 0;
for( var j:int = 0; j < columnResult.length ; j++ )
{
var colSpan:int = this.getColSpan(columnResult[j]);
var item:String = removeformat(removetd(columnResult[j]));
//grab the header (this is which column the value will be added
var head:String;
if (colSpan >1){
head = headerArray[j];
span = colSpan;
} else {
if (span == 0){
head = headerArray[j];
} else {
head = headerArray[j+span-1]
}
}
//set the value to header (pair)
chartItem[head] = item;
}
//add the chartItem (row) to the main collection
arr.addItem(chartItem);
If i read the span attribute for the row, i set the NEXT row to be at column+previous colspan. then all the rows line up properly.
精彩评论