Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created November 7, 2018 12:40
Show Gist options
  • Save exclusiveTanim/1094b4697f5a16c94e102d7d98612f49 to your computer and use it in GitHub Desktop.
Save exclusiveTanim/1094b4697f5a16c94e102d7d98612f49 to your computer and use it in GitHub Desktop.
Tableview search bar workaround
var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});
var self = Ti.UI.createView({
borderRadius : 10,
backgroundColor : 'red',
});
win.add(self);
var label1 = Ti.UI.createLabel({
text : 'Este es el Titulo',
color : "#333",
font : {
fontSize : 12
}
});
var toolbar = Ti.UI.createToolbar({
items : [label1],
top : 0,
});
var tableData = [];
for (var i = 0; i <= 50; i++) {
var row = Ti.UI.createTableViewRow({
id_colu : i,
title : 'columna' + i,
height : 40
});
var title = Ti.UI.createLabel({
text : 'otracolu' + i,
});
row.add(title);
tableData.push(row);
}
var searchBar = Ti.UI.createSearchBar({
barColor : '#000',
showCancel : true,
height : 43,
top : 5,
filterAttribute : 'title'
});
var table = Ti.UI.createTableView({
data : tableData,
objName : 'table',
search : searchBar,
filterAttribute : 'title',
scrollable : true,
top : 90,
bottom : 10,
});
table.addEventListener('click', function(e) {
Ti.API.info(e);
setTimeout(function(f) {
table.scrollToIndex(e.index, {
animated : false,
position : Ti.UI.iOS.TableViewScrollPosition.TOP
});
}, 1);
});
win.add(toolbar);
self.add(table);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment