简体   繁体   中英

Autocomplete for textfield in Sencha Touch?

I'm making an flight search app with Sencha Touch and have encountered a small problem.

I want to create a textfield for all the airports and need autocomplete functionality for in order to make it easy for the user to choose departure airport and return airport. How can i implement this? The airports will be loaded via XML-schema and I can't seem to find any good documentation for this feature.

Thanx in advance!

Since there were no custom components out there and I needed something like this myself as well, I smashed it together.

So, here it is. Sencha Touch 2 Autocomplete Textfield component: https://github.com/martintajur/sencha-touch-2-autocomplete-textfield

It currently uses AJAX request response for populating the autocomplete matches. It also supports custom input by the user.

When serializing the form data, the value of this type of input will be:

  • the selected item ID in case user has selected a matched autocomplete result
  • the typed text when the user has not chosen an autocomplete result

It is very basic at the moment and completely driven by own need for such a control. Feel free to fork, modify, adapt. It's MIT-licenced.

I think you should use a searchfield instead of textfield as suggested by @Ismailp,

Then you should create a popup(a panel) in its keyup event, which should contain a list of Airports.

Go through the hidden folder list-search in the example folder in downloaded sencha framework.It shows how to search through a list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM