Question

I have an issue which i can't solve at the moment, a little help would be much appreciated. A local XML file is loaded into a HTTPservice and load the data into a DataGrid. The local file contains information about locally stored files.

Just to be secure and sure, when the AIR app loads, i want to run through the loaded datagrid and check if the local file exists. If it doesn't exist, i want to delete the row in the datagrid.

Doing that i get this annoying error: The supplied index is out of bounds.

I know that, deleting an element in the datagrid will result in new indexes which causes this error.

Thanks for your advice!

public function checkiffileislocal(event:Event):void{

            var i:int;
            var count:Number = (dgUserRequest.dataProvider as ICollectionView).length;

            for (i=0;i < count;i++)
            {

                dgUserRequest.selectedIndex = i;
                if (File.applicationStorageDirectory.resolvePath(dgUserRequest.selectedItem.id).exists == false)
                {   
                    dgUserRequest.removeChildAt(dgUserRequest.selectedIndex);
                }

            }


        }
Was it helpful?

Solution

It sounds to me like you want to delete an item from the dataProvider; not a visual child of a DataGrid.

The rows of a DataGrid are not its children.

The rows/columns are created automatically based on the number of items in the dataProvider. You should not be trying to manipulate the rows / column objects directly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top