Home > DeveloperSection > Forums > Implement searchfield functionality in sencha touch
Takeshi Okada
Takeshi Okada

Total Post:89

Posted on    May-31-2013 1:26 AM

 Sencha Touch Sencha Touch 

 1 Reply(s)
 1914  View(s)
Rate this:
Hi Expert!

I am getting problem that how to implement search field on tree store getting data from the server in sencha touch. Any working code will be appreciated.

Thanks in advance! 


Total Post:604

Posted on    June-01-2013 12:41 AM

Hi Takeshi!

Assuming the data is already in the store when you search this isn't too difficult to implement using the methods referenced by speznaz.

In your view have a xtype "searchfield" or "textfield".

    xtype: "searchfield",

In the controller bind a "keyup" event to this field.

refs: {
   searchfield: 'mypanel searchfield'
control: {
   searchfield: {
      keyup: 'doSearch'

For your function to search something like:

doSearch: function(searchfield, e, eOpts) {
     var searchterm = searchfield.getValue();
     var store = Ext.getStore('myStore');

     // Now just customise the search options
     store.find(fieldName, value, [startIndex], [anyMatch], [caseSensitive], [exactMatch] );

This is assuming you want to search on keyup. You may want to use the "action" event instead.

I hope it helpful for you.

Modified On Jun-01-2013 12:44:47 AM

Don't want to miss updates? Please click the below button!

Follow MindStick