wiln / flexlib

Automatically exported from code.google.com/p/flexlib
0 stars 0 forks source link

TreeGrid openItemAt Error #170

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Define a tree using TreeGrid; the tree has two nodes at root level
2. Add an function in action script to run following code, to open the two 
nodes automatically.

var selItem1:Object = (tg.dataProvider as ArrayCollection).getItemAt(0);
var selItem2:Object = (tg.dataProvider as ArrayCollection).getItemAt(1);
tg.openItemAt(1, selItem2);
tg.openItemAt(0, selItem1);

3. Run it
4. Leafs of the second node are displayed under the first node.

What is the expected output? What do you see instead?
expected: leafs of the second node should be displayed under it.
But, they are displayed under the first node.

What version of the product are you using? On what operating system?
V2.4 windows

Please provide any additional information below.

Original issue reported on code.google.com by zhaotia...@gmail.com on 3 Nov 2008 at 3:34

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 8 Jan 2009 at 6:06

GoogleCodeExporter commented 8 years ago
Try changing your open itemAt method to look like this:

/**
     * 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:21

GoogleCodeExporter commented 8 years ago
see: http://code.google.com/p/flexlib/wiki/FlexBuilderProject about how to 
re-compile
your code.

Original comment by bdub...@gmail.com on 19 Feb 2009 at 8:22

GoogleCodeExporter commented 8 years ago
given solution is not working 

Original comment by riteshya...@gmail.com on 23 Mar 2010 at 10:51