Sencha Touch 过滤器由商店提供
代码:
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);
},
在我的模型中,我有四个字段:
姓名、年龄、性别、特征
我在这里尝试的是:
在页面上的列表中显示数据库的内容,因为列表很长,我想搜索,当用户在搜索字段中写入查询并按下搜索按钮,调用 searchButtonTap
处理程序,该处理程序尝试过滤并显示名称与查询中的名称类似的列表,我也尝试过 filterBy
但这也不起作用。请让我知道出了什么问题?
谢谢。
Code:
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);
},
in my models i have four fields:
Name, Age, Sex, Charecteristic
What i am trying over here is:
display the content of my database in a list on the page, since the list is long i wanted to search, when user writes the query in search field and presses the search button, the searchButtonTap
handler is invoked which tries to filter and display the list with names similar to the ones in query i also tried filterBy
but that too did not work. Please let me know whats wrong?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以尝试这样:
you can try this way: