Open GoogleCodeExporter opened 8 years ago
for module TreeGrid
Original comment by tica...@gmail.com
on 4 Apr 2007 at 10:26
Original comment by darron.schall
on 5 Apr 2007 at 10:36
There is a bug in the "openItemAt" method. The index used to insert rows does
not
take into account the sub children.
This code seems to work fine :
/**
* @return the number of rows added to the display model
*/
public function openItemAt( rowNum : Number, item : Object = null ) : Number
{
var uid : String = itemToUID( item );
_openItems[ uid ] = item;
this.selectedIndex = -1;
if ( item == null )
item = ListCollectionView( _displayedModel ).getItemAt( rowNum );
// add the rows for the children at this level
for ( var i : int = 0; i < _dataDescriptor.getChildren( item ).length; i++ )
{
ListCollectionView( _displayedModel ).addItemAt( _dataDescriptor.getChildren( item
)[i], rowNum + i + 1 );
}
var offset:Number = 0;
for ( i = 0; i < _dataDescriptor.getChildren( item ).length; i++ )
{
var vChild:Object = _dataDescriptor.getChildren( item )[ i ];
if ( isItemOpen( vChild ) )
{
offset += openItemAt( rowNum + i + 1 + offset, vChild );
}
}
return _dataDescriptor.getChildren( item ).length + offset;
}
Original comment by sro...@gmail.com
on 7 May 2007 at 12:41
thank you for this solution.
I replaced it in the source and recompiled the .swc and now its fixed :)
Original comment by g.kr.gu...@gmail.com
on 25 May 2007 at 6:47
Original comment by dmcc...@gmail.com
on 26 Dec 2007 at 11:44
obrigado pela solução!!! ajudou muito!!!
abraços Clayton
Original comment by clayton....@gmail.com
on 14 Mar 2008 at 8:13
Even better:
/**
* This method opens up an item at the row # passed in
*
* @return the number of rows added to the display model
* or return 0 if there were no children to open up (and thus no rows were added)
*/
public function openItemAt( rowNum : Number, item : Object = null ) : Number
{
//if there was no item passed in then retrieve it via row number
if ( item == null )
item = ListCollectionView( _displayedModel ).getItemAt( rowNum );
//if the item is not already open
if (!isItemOpen(item))
{
//add the item to the list of open items
var uid : String = itemToUID( item );
_openItems[ uid ] = item;
this.selectedIndex = -1;
//if there are childrent then go and open them up, otherwise skip to the bottom
and return 0
if ( _dataDescriptor.getChildren( item ) )
{
// add the rows for the children at this level
for ( var i : int = 0; i < _dataDescriptor.getChildren( item ).length; i++ )
{
ListCollectionView( _displayedModel ).addItemAt( _dataDescriptor.getChildren(
item )[i], rowNum + i + 1 );
}
var offset:Number = 0;
for ( i = 0; i < _dataDescriptor.getChildren( item ).length; i++ )
{
var vChild:Object = _dataDescriptor.getChildren( item )[ i ];
if ( isItemOpen( vChild ) )
{
offset += openItemAt( rowNum + i + 1 + offset, vChild );
}
}
//return the number of children that were opened
return _dataDescriptor.getChildren( item ).length + offset;
}
}
//if the item was already open then return 0 as well
return 0;
}
Original comment by bdub...@gmail.com
on 19 Feb 2009 at 8:24
Original issue reported on code.google.com by
tica...@gmail.com
on 4 Apr 2007 at 10:25