TableView Search Bar issue
Hello all. I'm facing crash issues or general malfunction when dealing with a search bar that is attached to a tableview. Basically, if the tableview has no data or all of its rows have been deleted, activating the search bar leads to a crash (trying to alter the search properties leads to no effect).
Can someone confirm this issue for me please or suggest a good workflow for quickly filtering table row entries in a dynamic table?
Using Ti Mobile SDK 1.1.2 - iphone project. Thank you very much.
2 Answers
-
This has happened to me as well.
One solution might be to hide the search bar when the table is empty:
tableView.setData(data); if(data.length) { tableView.search.show(); } else { tableView.search.hide(); }
The search bar should initially be hidden too, unless the table view holds data upon creation before
setData
is called. -
Don't attached the search bar to the tableView. Attach it to the window or view that contains both.
var win1 = Titanium.UI.createWindow({ //... }); var search = Titanium.UI.createSearchBar({ //... }); var searchResults = Titanium.UI.createTableView({ //... }); //Add everything to the window win1.add(search); win1.add(searchResults); win1.open();
Make sense?