[TIMOB-4456] Add cancel method to searchBar in a table view
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Matthew Apperson |
Assignee | Ingo Muschenetz |
Created | 2011-06-20T08:24:15.000+0000 |
Updated | 2015-04-13T20:11:07.000+0000 |
Description
Add the ability to do the following:
var win = Ti.UI.createWindow({backgroundColor:'white'});
var searchBar = Ti.UI.createSearchBar();
var tableview = Ti.UI.createTableView({
search: searchBar
});
win.add(tableview);
setTimeout( function() {
searchBar.focus();
setTimeout( function() {
searchBar.value = 'dog';
}, 500);
}, 500);
setTimeout( function() {
alert('fired!');
// This is the method desired
searchBar.cancel();
}, 3000);
win.open();
// With this code you can hide the SearchBar added in a TableView if you switch to another Tab Titanium.UI.setBackgroundColor('#000'); var tabGroup = Titanium.UI.createTabGroup(); var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); win1.addEventListener('focus', function(){ tableview.searchHidden = false; }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', window:win1 }); var searchBar = Ti.UI.createSearchBar({ cancel:false }); var tableview = Ti.UI.createTableView({ search: searchBar, data:[{title:'dog'},{title:"cat"},{title:"bird"}] }); win1.add(tableview); var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); win2.addEventListener('focus', function(){ tableview.searchHidden = true; }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); tableview.addEventListener('click', function (e){ alert("Index " + e.index + " \n" + e.rowData.title); }); tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.open();