动态填充Sencha Touch选取器

时间:2012-08-23 08:08:32

标签: sencha-touch

我在我的一个移动项目中使用Sencha Touch。作为其中的一个组件,我正在使用Picker。我知道选择器值来自“data”属性,这是一个包含对象的数组,如:

[{"text":"One","value":1},{"text":"Two","value":2},{"text":"Three","value":3}]

然而,我需要做的是 - 使用来自商店动态生成的数组中的值填充选择器。请问有人帮帮我吗?

感谢。

2 个答案:

答案 0 :(得分:1)

使用Ext.Picker.Slot允许您向其添加Ext.data.Store。商店将使您能够从服务器获取数据,并且将填充Picker插槽。

这是Sencha文档中给出的内容:

A general picker class. Ext.picker.Slots are used to organize multiple 
scrollable slots into a single picker. slots is the only necessary configuration.

The slots configuration with a few key values:

name: The name of the slot (will be the key when using 
getValues in this Ext.picker.Picker)
title: The title of this slot (if useTitles is set to true)
data/store: The data or store to use for this slot.
Remember, Ext.picker.Slot class extends from Ext.dataview.DataView.

答案 1 :(得分:0)

{   
    xtype:'picker',
    width:'100%',
    height:'100%',
    id:'chooseLocationRoomListPicker',
    baseCls:'pickerCls',
    cancelButton: false,
    doneButton: false,
    toolbar:false,
    slots : [{
             name:'chooseLocationRoomListPickerList',
             store: Ext.getStore('roomStore'),
             displayField: 'level',
             valueField: 'id',
             align:'center',
             value:'202'
    }]
}