Sencha touch Sencha Touch filterBy商店

Sencha touch Sencha Touch filterBy商店,sencha-touch,extjs-mvc,Sencha Touch,Extjs Mvc,代码: 在我的模型中,我有四个字段: 姓名、年龄、性别、性格 我在这里尝试的是: 在页面的列表中显示我数据库的内容,因为我要搜索的列表很长,当用户在搜索字段中写入查询并按下搜索按钮时,调用了searchButtonTap处理程序,该处理程序尝试筛选和显示名称与查询中的名称相似的列表,我也尝试了filterBy,但这也不起作用。请告诉我怎么了 谢谢。您可以这样尝试: searchButtonTap:函数(){ var searchTerm=this.searchField.getValue();

代码:

在我的模型中,我有四个字段:

姓名、年龄、性别、性格

我在这里尝试的是:

在页面的列表中显示我数据库的内容,因为我要搜索的列表很长,当用户在搜索字段中写入查询并按下搜索按钮时,调用了
searchButtonTap
处理程序,该处理程序尝试筛选和显示名称与查询中的名称相似的列表,我也尝试了
filterBy
,但这也不起作用。请告诉我怎么了

谢谢。

您可以这样尝试:

searchButtonTap:函数(){
var searchTerm=this.searchField.getValue();
如果(搜索术语){
this.myappsList.store.filterBy(函数(记录){
var fieldData=record.data.city.toLowerCase().indexOf(searchTerm);
如果(字段数据>-1)
返回记录;
});
}
否则{
this.myappsList.store.clearFilter();
}
},
this.searchField = new Ext.form.Text({
            displayField: 'name',
            valueField: 'name',
            editable: true,
            forceSelection: true,
            triggerAction: 'all',
            emptyText: 'Search...',
            selectOnFocus: true
    });

this.searchButton = new Ext.Button({// The button press will invoke the search action
        text: 'Go',
        handler: this.searchButtonTap,
        scope: this
    });

    this.topToolbar = new Ext.Toolbar({
                   items: [
                { xtype: 'spacer' },    
                    this.searchField,
                    this.searchButton,
                    { xtype: 'spacer' },
                ]
        });

searchButtonTap: function () {

        var searchText = this.searchField.getValue();
        console.log(searchText);
        //console.log(this.myappsList.store.getCount());
        console.log(this.myappsList.store.filter('name', searchText));
        //this.myappsList.store.filter(searchText);

    },