【发布时间】:2011-06-23 18:35:28
【问题描述】:
我有一个从 html 表动态构建的 AdvancedDataGrid。 html 由服务器提供,因此我的代码必须针对不同的列/行动态工作。
我正在构建列并且它们显示正确,但是当我开始添加行时,我遇到了问题。以下代码 sn-p 显示迭代所有列并将这些列中的每一列下的值添加到对象(以形成完整的行),然后将其添加到 ArrayCollection 稍后设置为 AdvancedDataGrid 的 dataProvider
//create an item to work with
var chartItem:Object = new Object();
for( var j:int = 0; j < columnResult.length ; j++ )
{
//this is the data that goes under the column (headerArray)
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);
我的问题是,当“head”的值为 0 时,如列标题为“0”,该项目将添加到位置 [0] 而不是作为字符串的 0。
我查找了一些示例并尝试了:
chartItem.head 但这只是假设列标题是“head”而不是获取 head var 的值
【问题讨论】:
标签: apache-flex actionscript-3 advanceddatagrid