Apache flex 组合框过滤器受其labelFunction flex的影响

Apache flex 组合框过滤器受其labelFunction flex的影响,apache-flex,flex4,flex3,flex4.5,Apache Flex,Flex4,Flex3,Flex4.5,我有一个comboBox,我为它实现了自定义过滤器,comboBox代码如下所示 <fx:Declarations> <s:ArrayCollection id="arrC"> <vo:ValueObject firstValue="430" secondValue="sampath"/> <vo:ValueObject firstValue="105" secondValue="New Y

我有一个comboBox,我为它实现了自定义过滤器,comboBox代码如下所示

<fx:Declarations>
        <s:ArrayCollection id="arrC">
            <vo:ValueObject firstValue="430" secondValue="sampath"/>
            <vo:ValueObject firstValue="105" secondValue="New York"/>
            <vo:ValueObject firstValue="896" secondValue="Xerox"/>
        </s:ArrayCollection>
    </fx:Declarations>

private function combineFunction(item:Object):String {
                return item.firstValue+"-"+item.secondValue;
            }

<local:AwadComboBox x="325" y="212" id="cb" dataProvider="{arrC}" labelFunction="combineFunction"/>
在这个组合框中,无论您输入哪个字符,如果该字符在下拉列表中,该值都应该被过滤,但是我的代码中有一个bug,请有人帮我修复一下


谢谢

听起来你需要一个自动完成组件。而不是建立自己的;我建议使用我们的:。它过去是一个商业产品,但现在是Apache许可下的开源产品。感谢您的回复,但我不能在我的项目中使用第三方swc,所以您能给我一个其他方法来解决这个问题吗?您可以自己编写代码。为什么不能使用第三方SWC?很多其他人为你做了“艰苦”的工作。
private var unfilteredDataProvider : IList;
            override public function set dataProvider(value:IList):void {
                super.dataProvider = value;

                unfilteredDataProvider = value;
            }

            override protected function textInput_changeHandler(event:TextOperationEvent):void {
                super.textInput_changeHandler(event);

                if (unfilteredDataProvider is ArrayCollection) {
                    ArrayCollection(unfilteredDataProvider).filterFunction = filterMatches;
                    ArrayCollection(unfilteredDataProvider).refresh();

                    super.dataProvider = new ArrayCollection(unfilteredDataProvider.toArray()); 
                }
            }

            protected function filterMatches(item:Object):Boolean {
                if (item is String) {
                    if(String(item).toLowerCase().indexOf(
                        textInput.text.slice(0,
                            textInput.selectionAnchorPosition).toLowerCase())>-1)
                        return true;
                }
                else if (labelField && labelField!= "") {
                    if(item.hasOwnProperty(labelField) && 
                        String(item[labelField]).toLowerCase().indexOf(
                            textInput.text.slice(0,
                                textInput.selectionAnchorPosition).toLowerCase())>-1)
                        return true;
                }

                return false;
            }