"filterAttribute" - How To Use?
How do you use the "filterAttribute" property on a TableView? I was told that you can use it to be able to have a SearchBar search custom Labels (Not from the TableView "Data"), but as of right now I have no idea how to get it working.
It says it's a string, but shouldn't it really be an array or object? Or am I totally doing this wrong?
I just need the SearchBar to search one field (A label) for text. Some code:
var searchbar = Ti.UI.createSearchBar({
hintText:'Search Episodes...',
barColor:'#000',
showCancel:false
});
searchbar.addEventListener('change', function(e)
{
return e.value; // search string as user types
});
searchbar.addEventListener('return', function(e)
{
searchbar.blur();
});
searchbar.addEventListener('cancel', function(e)
{
searchbar.blur();
});
var tableview = Titanium.UI.createTableView({
data:data,
search:searchbar,
searchHidden:false,
filterAttribute:''+jsoncats[c].title+'',
footerView:footerView,
maxRowHeight:100
});
4 Answers
-
Accepted Answer
I am sure you have solved this yourself by now, Colton, but just to let you know that, since your post, an explanation of
filterAttribute
has been added to the docs, here.Cheers
-
just figured this out myself, check this link here.
basically:
add a custom attribute like
customname: label.text
to your tablerows and then addfilterAttribute:'customname'
to your tableview. thecustomname
(or whatever custom attr you use) has to be in quotes. this threw me at first, but it's necessary. -
Bump
-
Any help at all? Bump.