[英]Flex 4 ComboBox stays open when filtered
編輯以獲取更多信息:
我有一個Flex 4應用程序,在DataGroup內部有一個外部ItemRenderer,用於重復表單。 DataGroup數據提供程序是ArrayCollection(coll_sites)。
在documentParent中,我有三個組合框(狀態,年份,區域),它們觸發直接在coll_sites上運行的篩選器功能。
itemRenderer具有一系列的textInputs和comboBoxes。 這些組合框中的三個與coll_sites中的字段(再次,狀態,年份和區域)相關聯,這些字段由上述parentDocument組合框過濾。
我遇到的問題是,在itemRenderer中,當字段是已過濾的字段之一時,itemRenderer ComboBox不會關閉。 如果未過濾,則沒有問題。 我已經確認問題ComboBox更新了ArrayCollection,除非選擇下拉菜單中的另一個Item,否則它不會關閉。
縮寫代碼:
篩選組合框(parentDocument):
<s:DropDownList id="cbo_filter_Year" x="156" y="36" dataProvider="{coll_YearList}" labelField="YEAR" prompt="Year" change="filter()"/>;
過濾功能:
private functionfilter():void {
coll_sites.filterFunction = filterSitesCollection;
coll_sites.refresh();
}
private function filterSitesCollection(item:Object):Boolean{
//I filter the Sites based on the selected combobox
var isMatch:Boolean = true;
if (cbo_filter_Year.selectedIndex != -1){
//if we have a year selected
if (item.YEAR.toString() != cbo_filter_Year.selectedItem.YEAR.toString()){
isMatch = false;
}
}
return isMatch;
}
調用parentDocument中的ItemRenderer:
<s:DataGroup itemRenderer="site_renderer" dataProvider="{coll_sites}" x="10" y="100">
<s:layout>
<s:VerticalLayout/>
</s:layout>
</s:DataGroup>
ItemRenderer:
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<s:BorderContainer x="0" y="0" width="653" height="215" borderWeight="2">
<s:Label text="Site ID" x="0" y="10"/>
<s:Label text="{data.SITE_ID}" x="0" y="25"/>
<s:Label text="Year" x="150" y="10"/>
<s:ComboBox id="cbo_Year" x="150" y="25" dataProvider="{parentDocument.coll_ShortYearList}" labelField="YEAR" selectedItem="{data.YEAR}" change="data.YEAR=cbo_Year.selectedItem.YEAR"/>
<s:Label text="Status" x="300" y="10"/>
<s:ComboBox id="cbo_Status" x="300" y="25" dataProvider="{parentDocument.coll_SiteStatus}" labelField="STATUS" selectedItem="{data.STATUS}" change="data.STATUS=cbo_Status.selectedItem.STATUS;"/>
</s:BorderContainer>
</s:ItemRenderer>
在上面的ItemRenderer代碼中,STATUS的ComboBox完全可以正常工作,但是YEAR在更改后保持打開狀態。 在我的完整代碼中,我有三個這樣的過濾字段,並且所有三個字段的行為完全相同。 其他六個未過濾的字段將適當關閉。
我知道這一定很簡單,但我很茫然。 我想念什么?
我不清楚是什么觸發了過濾; 以及在進行此過濾時ComboBox失去焦點。 如果ComboBox沒有失去焦點,並且ComboBox中的任何內容均未選中; 或未單擊向下箭頭; 那么沒有任何操作可以關閉下拉菜單。
您可以使用closeDropDown()方法強制關閉ComboBox。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.