2011-06-27 6 views
0

私は動的に行を追加していますが、適切な列の下にはないようです。私は 'headerArray'に私のヘッダをすべて持っていて、追加する必要があるデータは文字列 'item'にあります。AdvancedDataGrid Flex - 正しい列の下に行が追加されない

//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; 

すべてのヘッダーが正しく取得され、chartItemが設定されています(デバッガでインスペクションされます)。行の一部に値がある項目がある行(htmlからビルド)に移動すると、右側の列に情報が追加されず、左から右に移動して次の。

この動作は、chartItemが正しいヘッダー値とそれに対応する項目値を持っているために、奇妙なものですが、私は右の列の下に終わらないと言いました。 iは、行のスパン属性を読み取る場合

tableCollectionが後でグリッドのデータプロバイダとして設定されます

+0

は、オフ・バイ・ワンのエラーのように見えますが、これを見るためのコードがなくてもデバッグは難しいです。任意の方法でコードを貼り付けることができますか?あなたの "removeFormat"と "removetd"関数は何をしますか? – Kyle

+0

コメントありがとう、私はそれを解決したと思うが、私はまだ解決策を投稿できない、私は数時間待たなければならない。私は誰もが見ることができるようにそれを持っています。それは、追加しようとしているアイテムimからcolspan属性を取得し、そのcolspanをすべてのNEXT行に追加し、その量だけ効果的にそれらを押し出すことを伴います – leshow

答えて

1
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); 

(以降変更されていない)、iがカラム+前COLSPANになるように次の行を設定します。すべての行が正しく整列します。

関連する問題