AdvancedDataGrid Flex - 行未添加到正确的列下

发布于 2024-11-17 12:40:42 字数 777 浏览 3 评论 0原文

我正在动态添加行,但它们似乎没有位于正确的列下。我的所有标题都在“headerArray”中,我需要添加的数据位于字符串“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;

它正确获取所有标题并设置图表项(通过调试器检查)。当它到达一行(从 html 构建)时,其中有一个项目仅具有某些列的值,它不会在右列下添加信息,它只是从左到右并将其添加到下一张。

这种行为有点奇怪,因为 ChartItem 显然具有正确的标题值和相应的项目值,但就像我说的那样,它们最终没有出现在正确的列下。

tableCollection 稍后被设置为网格的数据提供者(此后未修改)

I'm dynamically adding rows and they don't seem to go under the proper column. I have all of my headers in 'headerArray' 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面犯桃花 2024-11-24 12:40:42
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);

如果我读取该行的跨度属性,我将下一行设置为列+上一个跨度。然后所有行都正确排列。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文