如何绑定阵列,以填充ExtJS的组合来arrystore [英] How to bind array to arrystore in order to populate combo in extjs
本文介绍了如何绑定阵列,以填充ExtJS的组合来arrystore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有数组
var cars = new Array('audi','benz','citron','nissan','alto');
我要添加这些数据来arraystore像下面
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,
});
的组合是显示阵列为A,B,C,N,一
The combo is showing only first letter of each word in the array as a, b, c, n, a
我怎样才能正确地DISPLY组合,因为我用的是一个编程填充,然后结合arraystore的ARRY
How can I properly disply the combo as the arry i am using is is populated programatically and then binding to arraystore
推荐答案
在ArrayStore消费数据的格式是一个数组的数组。重新格式化存储数据如下应当允许它的工作:
The format of data the ArrayStore consumes is an array of arrays. Reformatting your store data as follows should allow it to work:
var cars = [['audi'], ['benz'], ['citron'], ['nissan'], ['alto']];
从格式转换为所需要的格式很简单:
Converting from your format to the required format is simple enough:
for ( var i = 0, c = cars.length; i < c; i++ ) {
cars[i] = [cars[i]];
}
这篇关于如何绑定阵列,以填充ExtJS的组合来arrystore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文