Home > DeveloperSection > Forums > Sencha Touch Ext.picker setData not working correctly
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    May-31-2013 1:40 AM

 Sencha Touch Sencha Touch 
Ratings:


 1 Reply(s)
 1219  View(s)
Rate this:
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! 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-01-2013 12:49 AM

Hi Jacob!

You can use setSlots() method of picker class like:

picker.setSlots({
    name: 'limit_speed',
    title: 'Speed',
    data: [
        { text: '50 KB/s', value: 50 },
        { text: '100 KB/s', value: 100 }
    ]
}); 

I hope it helpful for you.

Don't want to miss updates? Please click the below button!

Follow MindStick