查找条件必须至少包含一个排序字段值

发布于 2024-08-16 03:51:14 字数 2631 浏览 5 评论 0原文

我有这个数据网格,其中 dataProvider 是 2 种不同类型的对象(FolderVO 和 FileVO)的 ArrayCollection。 我有一个大小列,在FolderVO 的情况下由名为contentSize 的属性填充,在FileVO 的情况下由size 属性填充(差异由itemrenderer 处理)。

这意味着我需要为 size 列实现一个排序函数,如下所示:

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

I have this datagrid which dataProvider is a ArrayCollection of 2 different types of objects (FolderVO and FileVO).
I have a size column which in the case of the FolderVO is populated by an attribute called contentSize and in the case of the FileVO it is populated by the size attribute (the difference is handled by a itemrenderer).

This means that I need to implement a sorting function for the size column, here it is:

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;
    }

The Function runs pretty well, but after the return statement I get this error:

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]

As you could notice, the error happens in the flex framework itself, not in my code.
So I'm realy stucked here. Help will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离旧人 2024-08-23 03:51:14

显然,该错误是因为在某些时候 Flex 框架假定 ArrayCollection 中包含的所有对象都具有 size 属性,因此即使我使用自定义排序,它也会尝试获取某些内容的值功能。

解决方案是向我的FolderVO 添加一个虚拟size 属性,默认值为0。

Apparently the error is caused because at some point the Flex Framework assumes that all the objects contained in the ArrayCollection have a size attribute so it attempts to get the value of it for something even when Im using a custom sorting function.

The solution was to add a dummy size attribute to my FolderVO with a default value of 0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文