Titanium Community Questions & Answer Archive

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

Picker Control inside TableViewRow

Not able to get the click events in the Picker, meaning I cannot select any of the items.

I have uploaded a functional app.js here

I am also getting this error message

2010-11-19 01:48:06.694 ocil[21322:207] -[UIPickerView setFrame:]: invalid height value 217.0 pinned to 216.0
2010-11-19 01:48:06.741 ocil[21322:207] -[UIPickerView setFrame:]: invalid height value 217.0 pinned to 216.0
— asked November 19th 2010 by Aaron Saunders
  • iphone
  • osx
3 Comments
  • Aaron, bearing in mind how well you communicate in the many answers you have kindly given to people within these pages, and also how you must no doubt appreciate how frustrating it is when people don't provide enough information, I must say that I am slightly disappointed by such a curt question from you.

    Come on, mate - give me some working code that I can drop into my app.js, and of course I will gladly try to help. :)

    — commented November 19th 2010 by Paul Dowsett
  • my bad, there is alot of code… I will break it out into a smaller test case

    — commented November 20th 2010 by Aaron Saunders
  • sample code uploaded here

    — commented November 20th 2010 by Aaron Saunders

3 Answers

  • Hi Aaron

    I am sorry that it has taken a while to get back to you, but this completely slipped my mind.

    I had to take a guess at what your objectives are. I hope this moves you a step closer to your goal. Certainly, the click events work in this version.

    Ti.UI.setBackgroundColor('#000');
    
    var win1 = Ti.UI.createWindow({  
        title:'Tab 1',
        backgroundColor:'#fff'
    });
    
    var tvData = [];
    var detailTableView = Ti.UI.createTableView( {
        // style : Ti.UI.iPhone.TableViewStyle.GROUPED,
    //    visible : true,
    //    width : '100%',
    //    height : '100%',
    //    scrollable : false,
        touchEnabled : false,
        allowsSelection : false
    });
    win1.add(detailTableView);
    
    
    for ( var j = 0, jlen = 10; j<jlen; j++){
        var l1 = Ti.UI.createLabel( {
            text : "THIS IS QUESTION "+j,
            font :{fontSize:18},
            left : 5
        });
        var row = Ti.UI.createTableViewRow( {
            className : "row2"
        });
    
        row.add(l1);
        var rowNum = 0;
        tvData.push(row);
    
        var pickerData = [];
        var choices = ["Choice 1", "Choice 2"];
    
        for ( var i = 0, ilen=choices.length; i <ilen ; i++){
            var thisPickerRow = Ti.UI.createPickerRow( {
                title : choices[i]
            });
            pickerData.push(thisPickerRow);
        }
    
        var picker = Ti.UI.createPicker( {
    //            selectionIndicator : true,
                choices : pickerData,
                questionNo:j
            });
    
            var row2 = Ti.UI.createTableViewRow( {
                height: 100
            });
            picker.add(pickerData);
    
            row2.add(picker);
            tvData.push(row2);
            picker.addEventListener('change',function(e)
            {
                Ti.API.info("On question "+e.source.questionNo+", "+" you changed to answer "+e.row);
            });
    }
    
    detailTableView.setData(tvData);
    win1.open();
    

    Good luck with it! :)

    — answered November 22nd 2010 by Paul Dowsett
    permalink
    2 Comments
    • Paul, your example does not work in 1.2.2, SDK 1.5.1 or 1.6 on IPAD. Any other ideas?

      — commented March 10th 2011 by Nicholas Vick
    • this doesnt work at all…. after all this time I got back to this

      — commented March 18th 2011 by Aaron Saunders
  • Did you have any luck with this code, Aaron? If I missed the point, and it isn't quite what you wanted, explain the details and I'll see what needs to be changed.

    — answered November 23rd 2010 by Paul Dowsett
    permalink
    1 Comment
    • I got distracted on another project, will check this out over the holiday weekend and let you know

      — commented November 25th 2010 by Aaron Saunders
  • Aaron

    I noticed you asked a question about raising tickets in this post. I think it's answered in the Contribute to Titanium guide, which is quite new so you probably have not seen it.

    Please excuse the off-topic post - the original post had been closed by the time I noticed your question.

    Cheers

    — answered December 16th 2010 by Paul Dowsett
    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.