Created
March 9, 2012 14:40
-
-
Save minhnc/2006778 to your computer and use it in GitHub Desktop.
Virtual Search Bar - Table hidden at fist time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var win = Ti.UI.createWindow({backgroundColor : 'white'}); | |
| var vsearchbar = Ti.UI.createSearchBar({top: 0, height: 40, hintText: 'Search', showCancel: true}); | |
| win.add(vsearchbar); | |
| var searchbar = Ti.UI.createSearchBar(); | |
| var tbl = Ti.UI.createTableView({ | |
| search: searchbar, | |
| visible: false, | |
| }); | |
| tbl.setData( fetchData(0, 5) ); | |
| win.add(tbl); | |
| win.open(); | |
| vsearchbar.addEventListener('change', function(e){ | |
| vsearchbar.hide(); | |
| tbl.visible = true; | |
| searchbar.focus(); | |
| searchbar.value = e.value; | |
| }); | |
| searchbar.addEventListener('cancel', function(e){ | |
| vsearchbar.value = ''; | |
| vsearchbar.show(); | |
| tbl.visible = false; | |
| }); | |
| function fetchData(start, len) { | |
| var rows = []; | |
| for (var i = 0; i < len; i++) { | |
| var tmp = i + start; | |
| rows.push({title: 'Row ' + tmp}); | |
| } | |
| return rows; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment