keal
23.01.2008, 13:54
Нашел такой код в интернете:
var _collection: ICollectionView;
if ( data is Array ) {
_collection = new ArrayCollection( data as Array );
} else if ( data is ICollectionView ) {
_collection = new ICollectionView( data );
} else if ( data is IList ) {
_collection = new ListCollectionView( IList( data ) );
} else if ( data is XMLList ) {
_collection = new XMLListCollection( data as XMLList );
} else if ( data is XML ) {
var xl: XMLList = new XMLList();
xl += data;
_collection = new XMLListCollection( xl );
} else if ( data is ArrayCollection ) {
_collection = data as ArrayCollection;
} else {
var tmp: Array = [];
if ( data != null ) {
tmp.push( data );
}
_collection = new ArrayCollection( tmp );
}
Из XMLListCollection и ListCollectionView знаю как привести к массиву. А из ICollectionView, не очень. :rolleyes: Подскажите, пожалуйста. :) Возможно есть более оптимальный способ, чем этот. :)
var _collection: ICollectionView;
if ( data is Array ) {
_collection = new ArrayCollection( data as Array );
} else if ( data is ICollectionView ) {
_collection = new ICollectionView( data );
} else if ( data is IList ) {
_collection = new ListCollectionView( IList( data ) );
} else if ( data is XMLList ) {
_collection = new XMLListCollection( data as XMLList );
} else if ( data is XML ) {
var xl: XMLList = new XMLList();
xl += data;
_collection = new XMLListCollection( xl );
} else if ( data is ArrayCollection ) {
_collection = data as ArrayCollection;
} else {
var tmp: Array = [];
if ( data != null ) {
tmp.push( data );
}
_collection = new ArrayCollection( tmp );
}
Из XMLListCollection и ListCollectionView знаю как привести к массиву. А из ICollectionView, не очень. :rolleyes: Подскажите, пожалуйста. :) Возможно есть более оптимальный способ, чем этот. :)