O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filtering the TableView using a SearchBar component

What happens when your user wants to search for all that data in your TableView? By far the easiest way is to use the SearchBar component. This is a standard control that consists of a searchable text field with a cancel button, that sits ontop of your TableView using the table view's searchBar property.

In this next recipe, we'll implement in our MyRecipes app a SearchBar component that filters our recipes based on the title property.

How to do it...

First of all, create a SearchBar component. Do this before your TableView is defined. Then we'll create the event listeners for SearchBar:

//define our search bar which will attach //to our table view var searchBar = Ti.UI.createSearchBar({ showCancel:true, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required