如何将数组绑定到 arrystore 以填充 extjs 中的组合
我有数组,因为
var cars = new Array('audi','benz','citron','nissan','alto');
我想将此数据添加到 arraystore,如下所示
var myStore = new Ext.data.ArrayStore({
data : cars ,
fields : ['names']
});
在将此数组存储绑定到组合时
var myCombo = new Ext.form.ComboBox({
store: myStore ,
displayField: 'name',
valueField: 'name',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Select a state...',
selectOnFocus: true,
});
组合仅显示数组中每个单词的第一个字母为 a、b、c、n、a
我如何正确显示我使用的 arry 的组合是以编程方式填充的,然后绑定到 arraystore
I am having array as
var cars = new Array('audi','benz','citron','nissan','alto');
I want to add this data to arraystore like below
var myStore = new Ext.data.ArrayStore({
data : cars ,
fields : ['names']
});
On Binding this array store to combo
var myCombo = new Ext.form.ComboBox({
store: myStore ,
displayField: 'name',
valueField: 'name',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Select a state...',
selectOnFocus: true,
});
The combo is showing only first letter of each word in the array as a, b, c, n, a
How can I properly disply the combo as the arry i am using is is populated programatically and then binding to arraystore
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者,如果您只是将数组作为存储配置传递,这也将起作用(假设是最新版本):
请注意,如果是这种情况,您不需要指定 displayField/valueField 。
Alternatively, if you just pass the array as the store config, that will also work (assuming a recent version):
Note you don't need to specify displayField/valueField if this is the case.
ArrayStore 消耗的数据格式是数组的数组。按如下方式重新格式化您的商店数据应该可以使其正常工作:
从您的格式转换为所需的格式非常简单:
The format of data the ArrayStore consumes is an array of arrays. Reformatting your store data as follows should allow it to work:
Converting from your format to the required format is simple enough: