我正在尝试从 json 存储创建一个多选列表,采用这种格式
[{"photo_id":1,"file_name":"test.JPG","x":123,"y":456},{"photo_id":2,"file_name":"test2.JPG","x":321,"y":765}]
多选列表会填充行,但不会在列表中显示 file_name
var storeVar = new Ext.data.Store({
extend: 'Ext.data.Model',
fields: ['photo_id', 'file_name'],
data: store // contains the json string
});
这是多选框
Ext.create('Ext.form.Panel', {
bodyPadding: 10,
frame: true,
width: '100%',
items: [
{
anchor: '100%',
displayField: 'file_name',
valueField: 'photo_id',
store: storeVar ,
xtype: 'multiselect',
fieldLabel: 'Select an image',
allowBlank: false
}
]
})
最佳答案
Grigor,你可以使用Ext.JSON.decode以 json 格式解码字符串:
var storeVar = new Ext.data.Store({
extend: 'Ext.data.Model',
fields: ['photo_id', 'file_name'],
data: Ext.JSON.decode(store) // contains the json
});
关于javascript - extjs 从 json 字符串中选择多选列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6866764/