Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Table view and search engine

$
0
0

If I have a tableview with tables, and a search bar at the top. How can I give a function to the search bar to only display that which is searched. In this case, if i search car1, I only want car1 to be viewed in the table view.

My code:


var tabGroup = Ti.UI.createTabGroup();

var win1 = Ti.UI.createWindow({ title:'Window 1', backgroundColor:'red' });

var data= [ {title: 'Car1', hasChild:true, test: 'car_1.js'}, {title: 'Car2', hasChild:true, test: 'car_2.js'}, {title: 'Car3', hasChild:true, test: 'car_3.js'}, {title: 'Car4', hasChild:true, test: 'car_4.js'} ];

var tableview = Ti.UI.createTableView({ data:data, top:45 });

tableview.addEventListener('click', function(e){ if (e.rowData.hasChild){ var newWin = Ti.UI.createWindow({ url: e.rowData.test, title: e.rowData.title });

    tab1.open(newWin);

} });

var search = Ti.UI.createSearchBar({ top:0, hintText:'Search for car' });

var view1 = Ti.UI.createView(); view1.add(tableview); win1.add(view1); win1.add(search); tabGroup.addTab(tab1); tabGroup.open();


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>