1

我在我的一个移动项目中使用 Sencha Touch。作为它的组件之一,我正在使用 Picker。我知道选择器值是从“数据”属性中获取的,该属性是一个包含对象的数组,如下所示:

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

但是我需要做的是 - 用从商店动态生成的数组中的值填充选择器。有人可以帮我解决这个问题吗?

谢谢。

4

2 回答 2

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.
于 2012-08-24T11:09:01.977 回答
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'
    }]
}
于 2013-09-23T06:08:17.983 回答