我有这个DataGrid,它的DataProvider是两种不同类型的对象(foldervo和filevo)的ArrayCollection。
我有一个大小列,在foldervo的情况下,它由一个名为contentsize的属性填充,而在filevo的情况下,它由大小属性填充(差异由itemrenderer处理)。
这意味着我需要为大小列实现一个排序函数,这里是:
protected function sortSize(dataA:Object, dataB:Object):int{
var order:int = 0;
if(dataA is FolderVO && dataB is FolderVO){
order = ObjectUtil.numericCompare(dataA.contentSize, dataB.contentSize);
}else if(dataA is FileVO && dataB is FileVO){
order = ObjectUtil.numericCompare(dataA.size, dataB.size);
}else if(dataA is FolderVO && dataB is FileVO){
order = 1;
}else if(dataA is FileVO && dataB is FolderVO){
order = -1;
}
return order;
}
函数运行得很好,但是在返回语句之后,我得到了这个错误:
Error: Find criteria must contain at least one sort field value.
at mx.collections::Sort/findItem()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\Sort.as:491]
at mx.collections::ListCollectionView/getItemIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:513]
at ListCollectionViewCursor/collectionEventHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:2154]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:833]
at mx.collections::ListCollectionView/internalRefresh()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1275]
at mx.collections::ListCollectionView/refresh()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:402]
at mx.controls::DataGrid/sortByColumn()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\DataGrid.as:3560]
at mx.controls::DataGrid/headerReleaseHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\DataGrid.as:4909]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at mx.controls.dataGridClasses::DataGridHeader/mouseUpHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\dataGridClasses\DataGridHeader.as:1259]
正如您可能注意到的,错误发生在flex框架本身,而不是我的代码中。
所以我在这里真的很笨。我们将非常感谢您的帮助。