【问题标题】:How to find ArrayList length after filtered in apache royale如何在 apache royale 中过滤后找到 ArrayList 长度
【发布时间】:2019-09-28 02:27:52
【问题描述】:

此代码 sn-p 来自 TDJ 列表

<j:Card>
   <html:H3 text="Jewel List"/>
   <j:List id="list" width="200" height="300" dataProvider="{simple}" change="onChange(event)"/>
            <j:TextInput width="200">
                <j:beads>
                    <j:TextPrompt prompt="filter list..."/>
                    <j:SearchFilterForList list="{list}"/>
                </j:beads>
            </j:TextInput>
            <j:Label id="selected" html="{describeItem(list.selectedItem)}"/>                               
</j:Card>

有 j:SearchFilterForList

我想知道它什么时候工作(在过滤器文本框中输入一些文本),如何找到过滤后的列表长度?

谢谢

【问题讨论】:

    标签: actionscript-3 mxml apache-royale


    【解决方案1】:

    只需使用最近添加的新“length”属性即可。 Tour de Jewel 也进行了更新,并在列表示例中展示了这个新的珠子属性的使用。

    <j:Label html="{'list filtered length: ' + filter.length}"/>
    <j:TextInput>
        <j:beads>
            <j:TextPrompt prompt="filter list..."/>
            <j:SearchFilterForList id="filter" list="{iconList}"/>
        </j:beads>
    </j:TextInput>
    

    注意这个珠子执行的过滤只是视觉上的,底层的dataProvider本身并没有被过滤。要获得 dataProvider 的过滤视图,您应该使用 ArrayListView API,这类似于 flex ListCollectionViewfilterFuncion

    【讨论】:

    • 卡洛斯,它奏效了。但是当我修改你的代码和跟踪过滤器长度时,为什么返回的值是未定义的? 私有函数 txtSearch_change(event:Event):void { trace("[过滤长度]", filter.length); //这个过滤器长度返回“未定义” }
    • 嗨,刚刚在代码和测试中尝试过这个,我得到了正确的数字,而不是未定义的。我认为您的代码中的某些内容可能会导致此问题?
    猜你喜欢
    • 2013-10-11
    • 2015-06-13
    • 2022-01-14
    • 1970-01-01
    • 2014-03-27
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多