Apache flex 使用多个实例时包含filterFunction问题的自定义组件
我有一个主应用程序,它使用两个自定义MXML DropDownList组件实例 我在自定义组件中包含了所有逻辑和查询,以查询MySQL并用结果填充ArrayCollection 在我的第一个下拉列表中,我想显示数据库中所有可用的货币 在第二个下拉列表中,我只想使用filterFunction显示CAD和USD货币 我不知道为什么,但一旦filterFunction应用于第一个元素,第二个元素就好像它们共享同一个currenceslist变量一样(这是我的问题) [Bindable]对于currenceslist,需要将其绑定到我的aSyncListView public要在主应用程序中使用,需要使用currenceslist 不管我的变量是公共变量还是私有变量,我都有相同的错误。。。请查看此消息末尾的输出Apache flex 使用多个实例时包含filterFunction问题的自定义组件,apache-flex,components,arraycollection,filterfunction,Apache Flex,Components,Arraycollection,Filterfunction,我有一个主应用程序,它使用两个自定义MXML DropDownList组件实例 我在自定义组件中包含了所有逻辑和查询,以查询MySQL并用结果填充ArrayCollection 在我的第一个下拉列表中,我想显示数据库中所有可用的货币 在第二个下拉列表中,我只想使用filterFunction显示CAD和USD货币 我不知道为什么,但一旦filterFunction应用于第一个元素,第二个元素就好像它们共享同一个currenceslist变量一样(这是我的问题) [Bindable]对于curre
我的主应用程序中的呼叫如下所示:
<mx:Form>
<formElems:DropDownListCurrencies id="product_cost_price_curr"
currencyCadUsdOnly="true"/>
<formElems:DropDownListCurrencies id="product_price_curr"/>
</mx:Form>
id:product_prices_curr (getAllCurrencies)
id:product_cost_price_curr (getAllCurrencies)
id:product_prices_curr, currencyCadUsdOnly:true, currenciesList.length:7 (BEFORE filterFunction)
id:product_prices_curr, currencyCadUsdOnly:true, currenciesList.length:2 (AFTER filterFunction)
id:product_cost_price_curr, currencyCadUsdOnly:false, currenciesList.length:2 (BEFORE filterFunction)
id:product_cost_price_curr, currencyCadUsdOnly:false, currenciesList.length:2 (AFTER filterFunction)
谢谢你的帮助尝试将代码更改为以下内容:
if (currencyCadUsdOnly == true) {
currenciesList = new ArrayCollection(currenciesList.source);
currenciesList.filterFunction = filterCadUsdOnly;
currenciesList.refresh();
}
希望这有帮助 每当您需要在多个位置使用不同的过滤器来创建相同的列表时,您需要的是ListCollectionView。这样,您就可以对其应用过滤器,而不会影响原始列表。这很容易:
var secondList:ListCollectionView = new ListCollectionView(originalList);
您的第二个列表
可以有任何您喜欢的过滤器,而不会影响原始列表,并且在添加项目或从原始列表
中删除项目时进行更新
请看这里:非常感谢。在我的组件中声明私有ListViewCollection使事情变得非常简单。工作起来很有魅力!
var secondList:ListCollectionView = new ListCollectionView(originalList);