Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

"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
        });
— asked September 29th 2010 by Colton Arabsky
0 Comments

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

    — answered May 6th 2011 by Paul Dowsett
    permalink
    1 Comment
    • This page is dead

      — commented November 7th 2011 by Rainer Schleevoigt
  • just figured this out myself, check this link here.

    basically:

    add a custom attribute like customname: label.text to your tablerows and then add filterAttribute:'customname' to your tableview. the customname(or whatever custom attr you use) has to be in quotes. this threw me at first, but it's necessary.

    — answered May 6th 2011 by Kelly Redd
    permalink
    0 Comments
  • Bump

    — answered September 29th 2010 by Colton Arabsky
    permalink
    0 Comments
  • Any help at all? Bump.

    — answered September 29th 2010 by Colton Arabsky
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.