我有一个JSON数据存储用于组合框选择工作正常,但是我希望将自定义记录添加到组合框并且它不工作。这里是我的代码:将自定义记录添加到组合框的JSON数据存储(ExtJS)
注:我删除了一些代码,以便于阅读。
var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'ajax.aspx?type=CR'
}),
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'clientId'
}, [
{name: 'name', mapping: 'clientName'},
{name: 'address', mapping: 'clientAddress'}
])
});
// add the Other record
// create a Record constructor from a description of the fields
var TopicRecord = Ext.data.Record.create([ // creates a subclass of Ext.data.Record
{name: "id"},
{name: 'name'},
{name: 'address'}
]);
// create Record instance
var myNewRecord = new TopicRecord({
id: Ext.id(),
name: 'Other',
address: 'Other'
});
ds.add(myNewRecord);
ds.commitChanges();
var carrierSearch = new Ext.form.ComboBox({
// removed some code here
onSelect: function(record){
carrierSearch.setValue(record.data.name);
document.getElementById(carrierIdHidden).value=record.id;
fieldOnBlurPost(document.getElementById(id), page, true);
carrierSearch.collapse();
}
});
为什么下的部分“//添加其他记录”任何想法(直到ds.commitChanges();)不加入我的自定义记录?
感谢,
Domenic
我在http://stackoverflow.com/questions/8912160/issues-with在Ext.data.store类似的问题-ext-data-store-and-listview-in-sencha-touch-javascript – user1152262 2012-01-18 15:07:54