我有一个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"/>
组合框是使用自定义过滤器实现的,该过滤器扩展了组合框
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;
}
在这个组合框中,输入你输入的字符,如果该字符在下拉列表中,该值应该被过滤但我的代码中有错误,有人可以帮我解决这个问题。
谢谢!