Hello all,
I have a JSON data store used for a combobox selection which is working fine, however I wish to add a custom record to the combobox and it isn't working. Here is my code:
Note: I removed some of the code to make it easier to read.
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();
}
});
Any ideas on why the section under "// add the Other record" (up until ds.commitChanges();) isn't adding my custom record?
Thanks,
Domenic