Created
November 7, 2018 12:40
-
-
Save exclusiveTanim/1094b4697f5a16c94e102d7d98612f49 to your computer and use it in GitHub Desktop.
Tableview search bar workaround
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 : '#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