PDA

View Full Version : [Solved]Adding a new element to Database driven ComboBox



rehanazher
11 Aug 2009, 6:08 AM
I have three linked combobox on my form panel. I want to add one extra option to the last combo boxes for user to select.

I have tried following but it dose not seems to work(following code is under listners->selectionchange of 2nd combo):




a=Ext.getCmp('cmbrname').getValue(); //GET PARENT COMBO SLECTION VALUE
var devicecombo = Ext.getCmp('idcombo'); //GET 3RD(CHILD) COMBO BOX BY ITS ID
devicecombo.store.reload({params:{id1: a}}); //RELOAD THE BASED ON PARENT COMBO SELECTION
MyRecordType = Ext.data.Record.create(['deviceID', 'deviceName']); // CREATE NEW RECORD TYPE
myrec = new MyRecordType({"deviceID":"100", "deviceName":"NO PATCHING DEVICE"}); // CREATE NEW RECORD
devicecombo.store..add(myrec); //ADD NEW RECORD
Following is the JSON Response of the store reload:
{rows:[{"deviceID":"2","deviceName":"ODF1"},{"deviceID":"3","deviceName":"ODF2"},{"deviceID":"4","deviceName":"ODF3"}]}


Can anyone help me through this.


Thanks and Best regards,

rehanazher
11 Aug 2009, 6:30 AM
I got it thanks all for viewed:

i moved my following code :


MyRecordType = Ext.data.Record.create(['deviceID', 'deviceName']);
myrec = new MyRecordType({"deviceID":"100", "deviceName":"NO PATCHING DEVICE"});
var devicecombo = Ext.getCmp('idcombo');
devicecombo.store.add(myrec);
to:


dsDeviceByRackID.on("load", function() {
MyRecordType = Ext.data.Record.create(['deviceID', 'deviceName']);
myrec = new MyRecordType({"deviceID":"100", "deviceName":"NO PATCHING DEVICE"});
var devicecombo = Ext.getCmp('idcombo');
devicecombo.store.add(myrec);
});