Titanium Community Questions & Answer Archive

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

create a tableview and detail view from database

HI

I have created a tableview (50 items) and detail view for each row on an app in development (non database), the app now needs 350 items and subsequent detail views. If so, is there a simple example to open an sqlite database, populate a tableview and link to a detail view all created from the database? I have read and sampled the pdfs on the site and seen the 'persistence' sample but a tableview to detail view sample would really cut out some development time. Can anyone point me in the right direction.
thanks

— asked October 22nd 2010 by Thomas Wilson
  • database
  • detailview
  • sqlite
  • tableview
0 Comments

5 Answers

  • I need help too!

    — answered October 27th 2010 by Nils D
    permalink
    0 Comments
  • I think I understand the question, and I think I have code to help you. My first app is a joke database with table views. http://bit.ly/cleanjokes First table view is category. Click on category, which opens a new table view to list of joke titles. Click on a title, which opens a web view to show the joke.

    All of this data (categories table, jokes table) is stored in a SQLlite database. So there is only one page of tableview code, and the rows change based on user clicks, pulling data from the database on demand.

    Is that close to what you're looking for? If so I'll post some (cleaned up and edited) code tonight for you.

    Todd

    PS - contact me if you want a promo code for the app (US iTunes store only). http://www.prairiewest.net/contact.php

    — answered October 27th 2010 by Todd Trann
    permalink
    1 Comment
    • HI Todd

      That would be great many thanks!!!!! Should really help with the app.
      Tom

      — commented October 27th 2010 by Thomas Wilson
  • So, if I am not mistaking, you made a tableview with 50 records, and then 50 views with details for those records on the tableview. If that is the case, no offence, but that is just bad thinking. If there are more than 3 views with the same layout, you have to make it generic. And even 3 is a big number.

    I am new to Titanium, so this may not be the most advised answer, but with my 3 years web development background I would take this approach:

    Read your data for the tableview from the database, construct the tableview, create a detail view, but do now open it.
    Upon click on the tableview, pass the id of the current row to the detail view, fetch the description for that row from the database, add it to the view and then show it. Going back should be just a matter of closing it, and next time doing it the same way. It would not take more than 30 new lines of code to your existing app.

    This is how i would do this. Hope it helps.

    — answered October 27th 2010 by Vali Filip
    permalink
    0 Comments
  • How can i reload the tableview on focus?

    — answered September 15th 2012 by Graham Jeffrey
    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.