PDA

View Full Version : Dynamically fill Picker



Kurt001
8 Mar 2011, 1:37 AM
Hi,

I am trying to use one picker with different content.
To do so I am trying to set the data from the slots to a different data store.

What am I doing wrong:


Ext.regModel('PickerModel', {
fields: ['text', 'value']
});

var storePicker = new Ext.data.JsonStore({
model : 'PickerModel',
data: [
{text: 'All', value: 0},
{text: 'Main', value: 100},
{text: 'Another', value: 101}
]
});
var myPicker = new Ext.Picker({
doneButton: 'Done Well',
fullscreen: true,
modal: true,
height: 400,
enter: 'bottom',
exit: 'bottom',
floating: true,
slots:
[{
name : 'myPicker',
title: 'Show some values',
data : storePicker

}],

});


Best Kurt

alanrosenthal
8 Mar 2011, 1:40 PM
Hi, did you get dynamically changing store in picker to work? - Alan

Kurt001
8 Mar 2011, 2:16 PM
Hi Alan,

no, did not get it to work.

Any ideas?

Kurt001
14 Mar 2011, 2:34 AM
Here is my solution:



/**
* Function is called to create the Picker content filling into myPicker
*/
var changeFilter = function(listItem){
var struktur = {
id:'PickerId',
name : 'PickerName',
title: 'test',
data : []
};
// you have to create the structure to fill the list with items from corresponding array
var arrayLength = ((myArray) / 2);
for(var i =0; i<arrayLength; i++){
structure[i] = {text: "here goes dynamically created text", value : i};
}
//add structure to the previous created picker
myPicker.add(structure);
// doLayout has to be called, otherwise the picker will only be filled once
picker.myPicker.doLayout();
picker.myPicker.show();
};
Remember to clear the picker on cancel and done with:

thisPicker.removeAll();Best
Kurt

Riaz
28 Mar 2011, 6:39 PM
How do I get selected text?

Example code:



var picker = new Ext.Picker({
slots: [{
name: 'ProjectPicker',
title: 'ProjectPicker',
data: [{ text: 'Project01', value: 'Project01' },
{ text: 'Project02', value: 'Project02' },
{ text: 'Project03', value: 'Project03' },
{ text: 'Project04', value: 'Project04'}]
}],


doneButton: {
text: 'Done',
handler: function () {
var SelectedValue = ???????????; //need code for selected text
alert(electedValue);
}
}


});
picker.show();

Riaz
29 Mar 2011, 2:35 PM
Any idea?

Riaz
29 Mar 2011, 7:15 PM
Why 'getValue' method is not working? Or how do I use this method to get selected value?

OOPS!

It is working now.



doneButton: {
text: 'Done',
handler: function () {
var xyz = picker.getValue();
alert(Ext.encode(xyz));


}
}