如何将对象转换为数组,并将中的值设置为sencha中的selectfield
How to convert object to array and set value in to selectfield in sencha
实际上我从服务器上得到了国家:英格兰,那么如何设置selectfield那个英格兰。我无法在选择字段中设置。
在其他文本字段中,我是这样管理的;
Ext.getCmp('email').setValue(email);
但为什么不在selectfield中工作呢
我有很好的sencha。现在我想转换数组。
var testcountry= Ext.create('Test.store.CountryList');
console.log("Length of Country==="+testcountry.getCount());
console.log("Country==="+testcountry);
for (var i = 0 ; i < testcountry.getCount() ; i ++){
console.log("Country Value--"+testcountry.getAt(i).data.country);
}
这里console.log("Country Value--"+testcountry.getAt(i).data.Country)
控制台中的所有国家/地区打印未定义。
型号:
Ext.define('Test.model.countryList', {
extend: 'Ext.data.Model',
alias: 'widget.countrylist',
config: {
fields: ['text']
}
});
店内:
Ext.define('Test.store.countryList', {
extend: 'Ext.data.Store',
config: {
storeId: 'countryList',
model: 'Test.model.countryList',
data: [
{ text: ''},
{ text: 'Japan'},
{ text: 'India'},
{ text: 'Spain'},
{ text: 'Australia'},
{ text: 'Sudan'},
{ text: 'Brazil'},
{ text: 'Mexico'},
{ text: 'England'},
{ text: 'Chaina'},
]
}
});
在控制台中,如下所示:
Length of Country===9
Country===[object Object]
Country Value--undefined
Country Value--undefined
Country Value--undefined
Country Value--undefined
Country Value--undefined
Country Value--undefined
Country Value--undefined
Country Value--undefined
如何打印所有国家/地区。
您的For循环片段应该如下所示:
for (var i = 0 ; i < testcountry.getCount() ; i ++){
console.log("Country Value--"+testcountry.getAt(i).getData().text);
}
您需要提到您在模型中使用的确切字段名称。
更新:
如果你想在选择字段中填充这个,你会这样做:
{
xtype: 'selectfield',
placeHolder: 'Select Country',
store: 'countryList'
}
相关文章:
- 如何设置html元素填充的动画
- 需要帮助设置json数组
- 如何在angularJS中编辑时,如果DB中的值为true,则设置复选框,如果值为false,则取消选中复选框
- 数组在递归方法中设置为null
- 如何在Bootstrap Modal中为动态点击生成的变量设置jade属性
- 无法在数据endVal中设置值=“”;{{ucount}}”;使用Angular JS的CountUp
- 而循环只设置php中输入字段中的第一个值
- Sencha触摸,字段设置为Change Listener
- 如何设置sencha组件的多重叠加模式
- Sencha Touch 创建无法在单击时销毁弹出窗口 Container.It 创建多个弹出窗口并创建设置数据值的错误
- 在sencha触摸应用程序中的动态分段按钮中设置宽度
- 在Sencha touch中的搜索字段上设置列表值
- 如何从阵列中设置Sencha Touch中的选择字段
- Sencha/ExtJS-记录[x].set()未保存/设置
- 如何将对象转换为数组,并将中的值设置为sencha中的selectfield
- Sencha Touch:如何为JsonStore中的数据设置限制
- Sencha触摸azure移动服务自定义登录如何设置用户
- 在我的sencha-touch/phonegap应用程序中设置IOS和Android字体的最佳方法是什么?
- Sencha Touch -为一组项目设置属性
- 如何在初始设置后引用(子)Sencha Touch中的组件