forum

Home / DeveloperSection / Forums / Sencha Touch Ext.picker setData not working correctly

Sencha Touch Ext.picker setData not working correctly

Anonymous User 2503 31-May-2013
Hi Expert!

I have been trying to figure out why I am not able to update the Sencha Touch picker data field (see the code at the end of post) using setData method. I created an array called slotsdata where I defined my data. The data look exactly like this:

{text: '50 KB/s', value: 50},  
         {text: '100 KB/s', value: 100},  
         {text: '200 KB/s', value: 200},  
         {text: '300 KB/s', value: 300} 
When I tried to set the data using setData() picker.setData(slotsdata); No error are displayed but picker does not display any data.

When I tried to update the data like this:
slots: [
{
name : 'picker_slot1',
title: 'slot1',
data: [slotsdata]
}
] It does not work. No errors in the console. The picker is empty.

The only way I can update is using this syntax:

slots: [
{
name : 'picker_slot1',
title: 'slot1',
data: slotsdata
}
]

I would like to be able to update my picker data using method #1. Can anyone help me with this issue. Any help will be appreciated.

This is the code:

myFunction: function(){  
var data = this.getData();  
var slotsdata = [];  
var pickerData = data.dosage.split(',');  
for( var i = 0; i < pickerData.length; i++ ){  
    slotsdata.push({text: pickerData[i], value: pickerData[i]})  
}  
var picker = Ext.create('Ext.Picker', {  
    slots: [  
        {  
            name : 'picker_slot1',  
            title: 'slot1',  
            data: slotsdata  
        }  
    ]  
});  
//this does not work  
//picker.setData(slotsdata);  
}

Thanks in advance! 

Updated on 01-Jun-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By