Reputation:
I need to implement a search field and I need that it is exactly the same like the one in the right-high corner http://docs.sencha.com/touch/2-0/#
for now i do:
//called on key up
onSearchQueryChanged: function(field) {
var queryString = field.getValue();
var store = Ext.getStore('Customers');
store.clearFilter();
if(queryString){
var thisRegEx = new RegExp(queryString, "i");
store.filterBy(function(record) {
if (thisRegEx.test(record.get('name')) || thisRegEx.test(record.get('code')))
return true;
};
return false;
});
}
},
//clearicontap
onSearchReset: function(field, b, c) {
var store = Ext.getStore('Customers');
store.clearFilter();
field.setValue('Search');
},
//focus
onMouseOn: function(field, b, c) {
field.setValue('');
},
the search work fine.. the only problem is that when I clear the field pressing the clear icon tap the field remain empty… but i want to re-write 'Search', like you can see in the onSearchReset function….
there is a solution? thanks!
Upvotes: 0
Views: 692
Reputation: 7055
If you are using xtype searchfield
then just apply placeHolder
config. Even if you are not using xtype:searchfield
then also you can use placeHolder
. You don't need to manually set it back to default value.
xtype: 'searchfield',
label: 'Query',
placeHolder:'Search',
name: 'query'
Upvotes: 1