Titanium Community Questions & Answer Archive

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

Creating subpages in a tableview from JSONfile ???

Hello;

I've succeeded in parsing a JSON to populate a tableview, but i was wondering if it's possible to make the rows of the 'JSON-populated' tableview 'clickable' to open a new json-populated tableview

(for instance: Animals (Dogs - Cats - Birds) and when 'Dogs' is clicked a new tableview opens with all the dogs

(hope i made myself a bit clear)

Kind Regards;

— asked November 30th 2010 by Benoit Willaert
  • json
  • subpage
  • tableview
1 Comment
  • Thanks for the answers; Could anyone show how to add a subpage in the twitter app example in Kitchensink?

    — commented December 1st 2010 by Benoit Willaert

2 Answers

  • here is some code I wrote that has a two level deep navigation for iOS

    you have already solved the parsing of the JSON and the table creation so you should be all set. I would suggest storing some value in each row so on the "click" event you can retrieve the appropriate JSON data for rendering the detailed table view

    — answered December 1st 2010 by Aaron Saunders
    permalink
    0 Comments
  • data = [
        {
            title: 'dogs',
            hasChild: true,
            names: [
                {
                    title: 'fluffy'
                },
                {
                    title: 'blackie'
                },
                {
                    title: 'noisy'
                } 
            ]
        },
        {
            title: 'cats',
            hasChild: true,
            names: [
                {
                    title: 'lazy'
                },
                {
                    title: 'sleepy'
                },
                {
                    title: 'hungry'
                } 
            ]
        }
    ];
    
    tv = Ti.UI.createTableView({data: data});
    Ti.UI.currentWindow.add(tv);
    
    tv.addEventListener('click', function(e) {
       if(e.rowData.names) {
          var newWin = Ti.UI.createWindow({title: e.rowData.title});
          var newTv = Ti.UI.createTableView({data: e.rowData.names});
          newWin.add(newTv);
          newWin.open();
       }
    });
    

    PS: did not test the code…

    — answered December 1st 2010 by soemarko ridwan
    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.