Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4456] Add cancel method to searchBar in a table view

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMatthew Apperson
AssigneeIngo Muschenetz
Created2011-06-20T08:24:15.000+0000
Updated2015-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();

Comments

  1. Miguel Vizcaino 2011-06-21

    // 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();

JSON Source