Titanium Community Questions & Answer Archive

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

Is there a way to programatically scroll to the bottom of a table view?

I have a table view with variable-sized rows and a footer for entering data. I need to be able to programatically scroll the table view to make the footer visible.

— asked December 1st 2010 by Jim Fulton
  • mobile
  • tableview
0 Comments

3 Answers

  • Jim

    You haven't stated your mobile platform. It's useful if you put this, along with your SDK version, in the tags of your question.

    For both platforms, there is TableView.scrollToIndex.

    In addition to this, for iOS only, there is iPhone.TableViewScrollPosition.

    Hope you find this useful

    — answered December 1st 2010 by Paul Dowsett
    permalink
    2 Comments
    • I didn't state a platform because I didn't think the question was
      platform specific. :)

      I happen to be developing against iphone now, but I'll be porting to
      android later.

      scrollToIndex will let me make sure a row is visible, but I need the
      footer to be visible. I tried using the index of the last row along
      with position:Ti.UI.iPhone.TableViewScrollPosition.TOP, but
      that won't make the footer visible if the last row fills the view.

      I tried a hack of adding a small row, scrolling to that, and then
      deleting the row. :) Unfortunately, adding and them immediately
      deleting a row causes the app to crash. :/

      — commented December 1st 2010 by Jim Fulton
    • Jim

      Questions are almost always platform-specific, as my answer showed. It would help if you could include it as a matter of course for future questions. Thanks :)

      — commented December 1st 2010 by Paul Dowsett
  • Can you just make the footer a separate view below the table? That way it would always be visible for entering data. Just trying to approach the stated problem from another perspective…

    — answered December 1st 2010 by Doug Handy
    permalink
    1 Comment
    • I've tried a number of variations on this.

      If I put the data entry view at the bottom of the window, it would get
      covered by the keyboard when it gets focussed. Initially, I hoped to
      have a UI that's similar the iPhone's messages app. I was dismayed to
      see that the text field was convered by the keyboard.

      Is there some clean general way to prevent a text field or text area
      from being convered by the keyboard? If so, I'd love to know it.

      The examples I've seen in the Kitchen Sink put text fields at the top
      of the window. There's a neat decoy in textfile_toolbar.js that seems
      to provide the iphone messages effect, except that when you pay
      attention to it, there are a number of things wronmg with it:

      • It creates a new text field in the keyboard toolbar that is
        disconnected from the original. That should be alright. You could
        just copy data from the toolbar text field to the original, but

      • The text field in the keyboard toolbar doesn't get focus unless the
        user clicks in it. You can't make it get focus programatically.

      • The animation is poor. I could live with this if I could make it
        work.

      — commented December 2nd 2010 by Jim Fulton
  • Is there a way to start the focus at the bottom. Instead of having it to move there?

    — answered November 18th 2011 by Leonardo Amigoni
    permalink
    1 Comment
    • well i think you can do that by putting some blank label at the bottom of the table and set the focus to that label when the window open. I really think this can solve your problem

      — commented November 19th 2011 by Nikunj Sakhrelia
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.