Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2344] Picker - Unable to add rows / columns dynamically

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-02-22T19:29:27.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy, Titanium SDK & CLI
Labelsios7, picker, titanium
ReporterManojkumar Murugesan
AssigneeRitu Agrawal
Created2014-02-13T11:37:51.000+0000
Updated2016-03-08T07:41:22.000+0000

Description

Alloy View
  <Picker id="picker" />
I'm adding the columns and rows dynamically on click of a button in the controller. But it is not at all showing a single row / column. I have attached the screen shot. Controller
var column1 = Ti.UI.createPickerColumn();
column1.addRow(Ti.UI.createPickerRow({title:'Bananas',custom_item:'b'}));
column1.addRow(Ti.UI.createPickerRow({title:'Strawberries',custom_item:'s', selected:true}));
column1.addRow(Ti.UI.createPickerRow({title:'Mangos',custom_item:'m'}));
column1.addRow(Ti.UI.createPickerRow({title:'Grapes',custom_item:'g'}));
	
var column2 = Ti.UI.createPickerColumn();
column2.addRow(Ti.UI.createPickerRow({title:'red'}));
column2.addRow(Ti.UI.createPickerRow({title:'green'}));
column2.addRow(Ti.UI.createPickerRow({title:'blue'}));
column2.addRow(Ti.UI.createPickerRow({title:'orange'}));
	
// 2 columns as an array
$.picker.add([column1,column2]);

Attachments

FileDateSize
iOS Simulator Screen shot 13-Feb-2014 5.05.39 PM.png2014-02-13T11:37:51.000+000039855

Comments

  1. Ritu Agrawal 2014-02-13

    Please attach a complete and runnable test case to diagnose the issue further.
  2. Manojkumar Murugesan 2014-02-14

    Here I have attached the sample code I used to test. On Click of the button I'm loading the picker columns and rows. I need this use case as I want to change the rows and columns based on the selected text field. Like a dropdown component. If you see the screen shot I attached earlier above you can understand my use case well. index.xml
       <Alloy>
       	<Window backgroundColor="white">
       		<Picker id="picker" />
       		<Button bottom="40dp" backgroundColor="#000" color="#fff" width="90%" height="50dp" onClick="doClick">Load Picker</Button>
       	</Window>
       </Alloy>
       
    index.js
       
       var heightDataSource = [];
       var feets = [];
       for (var i = 1; i <= 10; i++) {
       	feets.push({
       		title : i
       	});
       }
       heightDataSource.push(feets);
       heightDataSource.push([{
       	title : L("feet")
       }]);
       var inches = [];
       for (var i = 0; i < 12; i++) {
       	inches.push({
       		title : i
       	});
       }
       heightDataSource.push(inches);
       heightDataSource.push([{
       	title : L("inches")
       }]);
       
       function doClick(e) {
       	var pickerColumns = [];
       	for (var i in heightDataSource) {
       		var column = Ti.UI.createPickerColumn();
       		for (var j in heightDataSource[i]) {
       			column.addRow(Ti.UI.createPickerRow(heightDataSource[i][j]));
       		}
       		pickerColumns.push(column);
       	}
       	$.picker.add(pickerColumns);
       }
       
       $.index.open();
       
       
  3. Manojkumar Murugesan 2014-02-15

    Any update on this?
  4. Ritu Agrawal 2014-02-22

    Titanium does not support adding rows / columns to a picker dynamically. You can create your own picker if you need this functionality.
  5. Manojkumar Murugesan 2014-02-23

    Strange! I was able to do the same on 3.1.0 GA and it was working fine. I don't know what is wrong now.

JSON Source