SENCHA TOUCH EXT.PICKER SETDATA NOT WORKING CORRECTLY

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 1593  View(s)
Ratings:
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! 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Sencha Touch Ext.picker setData not working correctly

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!