Extjs组合框存储来自另一个对象的值
我有一个对象,它有一些值,我想显示在一个组合框中,我要将它添加到for循环内的表单面板中 这是对象的内容 但是在我的组合框中,我得到的数据是[object] 以下是我目前正在做的事情Extjs组合框存储来自另一个对象的值,extjs,combobox,extjs3,Extjs,Combobox,Extjs3,我有一个对象,它有一些值,我想显示在一个组合框中,我要将它添加到for循环内的表单面板中 这是对象的内容 但是在我的组合框中,我得到的数据是[object] 以下是我目前正在做的事情 for(var i = 0; i < data.length ; i++) { console.log('ad'); var storeStates = new Ext.data.ArrayStore({ fields: ['optionText'],
for(var i = 0; i < data.length ; i++)
{
console.log('ad');
var storeStates = new Ext.data.ArrayStore({
fields: ['optionText'],
data : [data[i].data.selectOptions.list[i].optionText]
});
var cb = new Ext.form.ComboBox({
fieldLabel: data[i].data.name,
hiddenName: 'fieldTypeName',
id: data[i].data.name.toString(),
valueField: 'optionText',
displayField: 'optionText',
typeAhead: true,
allowBlank: false,
mode: 'local',
selectOnFocus: true,
triggerAction: 'all',
emptyText: 'Survey Field Type',
disabled: this.existingField,
width: 190,
store: storeStates,
listeners: {
'select': function (combo, newValue, oldValue) {
}
}
});
Ext.getCmp('survey-field-form').add(cb);
//Ext.getCmp('survey-field-form').doLayout();
console.log('added');
for(变量i=0;i
}您需要将存储定义从
Ext.data.ArrayStore
更改为Ext.data.store
&数据为data[i].data.selectOptions.list
var storeStates = new Ext.data.Store({
fields: ['optionText'],
data : data[i].data.selectOptions.list
});
您需要将存储定义从
Ext.data.ArrayStore
更改为Ext.data.store
&数据为data[i].data.selectOptions.list
var storeStates = new Ext.data.Store({
fields: ['optionText'],
data : data[i].data.selectOptions.list
});
我认为您需要这样定义您的店铺以获得正确的显示:
var storeStates = new Ext.data.JsonStore({
data: data[i].data.selectOptions.list,
fields: [{name: "optionText", type: "string"}]
});
我认为您需要这样定义您的店铺以获得正确的显示:
var storeStates = new Ext.data.JsonStore({
data: data[i].data.selectOptions.list,
fields: [{name: "optionText", type: "string"}]
});
我通过创建一个读卡器和一个存储并将数据推送到存储中,然后像这样加载存储来解决这个问题
// create a Record constructor:
var rt = Ext.data.Record.create([
{name: 'optionValue'},
{name: 'optionText'}
]);
var myStore = new Ext.data.Store({
// explicitly create reader
reader: new Ext.data.ArrayReader(
{
idIndex: 0 // id for each record will be the first element
},
rt // recordType
)
});
var myData = [];
for(var j = 0; j < data[i].data.selectOptions.list.length; j++)
{
var optionText = data[i].data.selectOptions.list[j].optionText.toString();
var optionValue = data[i].data.selectOptions.list[j].optionValue.toString();
myData.push([optionValue, optionText]);
}
myStore.loadData(myData);
//创建一个记录构造函数:
var rt=Ext.data.Record.create([
{name:'optionValue'},
{name:'optionText'}
]);
var myStore=new Ext.data.Store({
//显式创建读卡器
读卡器:新Ext.data.ArrayReader(
{
idIndex:0//每个记录的id将是第一个元素
},
rt//recordType
)
});
var myData=[];
对于(var j=0;j
希望这对其他人有所帮助我通过创建一个读卡器和一个存储并将数据推送到存储,然后像这样加载存储来解决这个问题
// create a Record constructor:
var rt = Ext.data.Record.create([
{name: 'optionValue'},
{name: 'optionText'}
]);
var myStore = new Ext.data.Store({
// explicitly create reader
reader: new Ext.data.ArrayReader(
{
idIndex: 0 // id for each record will be the first element
},
rt // recordType
)
});
var myData = [];
for(var j = 0; j < data[i].data.selectOptions.list.length; j++)
{
var optionText = data[i].data.selectOptions.list[j].optionText.toString();
var optionValue = data[i].data.selectOptions.list[j].optionValue.toString();
myData.push([optionValue, optionText]);
}
myStore.loadData(myData);
//创建一个记录构造函数:
var rt=Ext.data.Record.create([
{name:'optionValue'},
{name:'optionText'}
]);
var myStore=new Ext.data.Store({
//显式创建读卡器
读卡器:新Ext.data.ArrayReader(
{
idIndex:0//每个记录的id将是第一个元素
},
rt//recordType
)
});
var myData=[];
对于(var j=0;j
希望这对其他人有所帮助当我按照你说的那样做时,我得到了这个错误“Uncaught TypeError:无法读取未定义的属性'readRecords'”你使用的是哪个版本基于你的对象我在这里复制了它,它似乎在3.3版上不起作用,我被这个版本卡住了,无法升级当我按照你说的那样做时,我收到这个错误“Uncaught TypeError:无法读取未定义的属性'readRecords'”您正在使用的版本基于您的对象我在这里复制了它,它似乎在版本3.3上不起作用,我被这个版本卡住了,无法升级它