Titanium Community Questions & Answer Archive

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

TableView with SearchBar will not scroll

I created a standard tableview snd added a search bar object to it using the code below. When the view appears the tableview cannot/will not scroll. If I click in the search field and immediately click cancel, the tableview starts to function (scroll) normally. I am adding the search bar like this:

var search = Titanium.UI.createSearchBar({
    showCancel:false,
    height:43,
    top:0
});

search.addEventListener('return',function(e){
    var swin = Titanium.UI.createWindow({
            url:'search_view.js',
            title:e.value,
            backgroundColor:'#FFF'
    });

    Titanium.UI.currentTab.open(swin,{animated:true});
});

var tableview = Titanium.UI.createTableView({
    search:search,
    searchHidden:false
});

Any help?

— asked July 20th 2010 by Ben Hornedo
  • scroll
  • searchbar
  • tableview
3 Comments
  • Ben

    You haven't stated your mobile platform or SDK versions. The tips given in the Participating in the Q&A section of the "Contribute to Titanium" guide will help you get more out of the Q&A.

    — commented December 30th 2010 by Paul Dowsett
  • I had this same problem on an app I was working on before. There seems to be no actual fix, I just did a hack-fix that right when the TableView was loaded I would "searchbar.focus();" then "searchbar.blur();". There would be a quick messup when it loads, but atleast you could scroll.

    I'm still waiting on Appcelerator to fix this problem.

    — commented February 11th 2011 by Colton Arabsky
  • Colton

    If you believe it is a bug, you need to create a usecase. See Creating Good Use-cases. If you send me a link to the usecase, I will verify it on my system, and then we can escalate it.

    Cheers

    — commented February 11th 2011 by Paul Dowsett

7 Answers

  • Stumbled across a solution. Set the 'search' property of the tableView after the tableView has been added to the window. Scrolls without first having to interact with the search bar.

    var win = Titanium.UI.createWindow();
    
    var search = Titanium.UI.createSearchBar({
        barColor:'#385292', 
        showCancel:false,
        hintText:'search'
    });
    
    var yourTableView = Titanium.UI.createTableView({
        data:data,
        searchHidden:false
    });
    
    win.add(yourTableView);
    yourTableView.search = search;
    

    Hope that helps you out…

    — answered April 7th 2011 by Tyler Peterson
    permalink
    1 Comment
    • Nice one Tyler, just ran into the same problem and this sorted it.
      Cheers.

      — commented April 11th 2011 by Terry Harmer
  • I have the same issue here, did you find any fix for it?

    — answered December 30th 2010 by B Ben
    permalink
    0 Comments
  • Same problem here.. no solution?

    — answered February 10th 2011 by Gerardo Lopez
    permalink
    0 Comments
  • try this:

    var tableview = Titanium.UI.createTableView({
        search:search,
        searchHidden:false,
        scrollable: true
    });
    
    — answered February 11th 2011 by Nele Debrouwer
    permalink
    0 Comments
  • It seems to be a problem with the Titanium SDK that has not been fixed since before 1.5.0. I'm still waiting for a fix for this. I seemed to "hack" this by quickly focusing then blurring the search bar (Or simply just focusing it and leaving it), which causes the TableView to become scrollable again.

    — answered March 14th 2011 by Colton Arabsky
    permalink
    0 Comments
  • Simply commenting out searchHidden:false worked for me. - If you can be without it.

    — answered May 3rd 2011 by JM Gleditsch
    permalink
    0 Comments
  • Standard info, first:

    Titanium Studio, build: 1.0.2.201107130739
    Use: iOS and Android Development

    The issue I am having with the iPhone and the search bar is that when I scroll down, I cannot seem to keep the search bar in a fixed position without sacrificing the user's ability to scroll.

    The goal is to keep the search bar up top and fixed. Would I be correct to say I need to create a View spot for it (all on it's own) within the Window I have?

    Thnx!
    -Jesse

    — answered August 13th 2011 by Jesse Benedict
    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.