2009-12-23 61 views
1

我有这个datagrid哪个dataProvider是2个不同类型的对象(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; 
    } 

函数运行得很好,但return语句后,我得到这个错误:

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框架本身,而不是在我的代码中。 所以我真的在这里被困住了。帮助将不胜感激。

回答

4

好吧,我发现我自己......

显然,错误造成的,因为在某些时候Flex框架假设包含在ArrayCollection中的所有对象有大小属性,以便它试图获取值甚至当我使用自定义排序功能的东西。

的解决方案是一个虚拟大小属性添加到我FolderVO以0

希望的默认值,这是有人在那里帮助。

Cheerz!

+1

谢谢!!!帮了我很多 – ufk 2011-01-18 12:56:16

相关问题