[AC-2344] Picker - Unable to add rows / columns dynamically
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2014-02-22T19:29:27.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Alloy, Titanium SDK & CLI |
| Labels | ios7, picker, titanium |
| Reporter | Manojkumar Murugesan |
| Assignee | Ritu Agrawal |
| Created | 2014-02-13T11:37:51.000+0000 |
| Updated | 2016-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
| File | Date | Size |
|---|---|---|
| iOS Simulator Screen shot 13-Feb-2014 5.05.39 PM.png | 2014-02-13T11:37:51.000+0000 | 39855 |
Please attach a complete and runnable test case to diagnose the issue further.
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
index.jsvar 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();Any update on this?
Titanium does not support adding rows / columns to a picker dynamically. You can create your own picker if you need this functionality.
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.