在Sencha Touch 2中为Dataview创建搜索器

时间:2012-04-16 17:28:41

标签: sencha-touch sencha-touch-2

在dataview组件中,我可以插入一个dataitem,但我如何插入一个搜索器?,如列表组件

1 个答案:

答案 0 :(得分:1)

数据视图和列表直接绑定到商店(Ext.data.Store)。因此,该商店发生的任何事情都会反映在视图中。

所以您需要做的是过滤商店。您可以使用商店中的filterfilterBy方法执行此操作。

更多信息:http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Store-method-filter

示例

var store = Ext.create('Ext.data.Store', {
    fields: ['text'],
    data: [
        { text: 'one'},
        { text: 'two'},
        { text: 'three'}
    ]
});

store.filter('text', 'one'); // will only show the one record