Flash builder: datagrid remove item - index out of bound
I have an issue wich i can't solve atm, a little helo would be much
appreciated. A local XML file is loaded into a HTTPservice and load the
data into a Datagrid. The local file cotains 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 doens't
exist, i want to detele 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 wich 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);
}
}
}
No comments:
Post a Comment