PDA

View Full Version : [CLOSED]ComboBox does not refresh records from file


naresh
02-03-2010, 10:34 AM
The combobox is not being refreshed when I add records to the file. It is refreshed when I exit and call the program again. In debug mode, I see all the records being retrieved, even the one added, but the only one missing in the combobox is the recent added record.

sean.lanktree
02-03-2010, 10:49 AM
Can you post the code of your combo box and the data store?
Additionally, please post the JSON response too.

naresh
02-03-2010, 11:38 AM
I have attached the code and the JSON response.


// holds the list of sales persons for the "form_SalespersonCombo" combobox...
//
var dsSalespersonCombo = new Ext.data.JsonStore({
totalProperty: 'totalCount',
autoload: true,
autoDestroy: true,
url: 'vvcall.pgm',
root: 'SALESPERSON',
fields: ['SLSLMN','SLNAME'],
baseParams: {
action: 'getSalespersonCombo',
pgm: 'osr1308'
}
});





var fsBroker = new Ext.form.FieldSet({
title: 'Broker/Sales Person',
iconCls: 'user',
labelAlign: 'right',
layout: 'table',
layoutConfig: {
columns: 4
},
items: [{
labelWidth:150,
layout: 'form',
items: [{

xtype: 'combo',
id: 'form_BrokerCombo',
labelAlign: 'right',
fieldLabel: 'Broker',
width: 170,
listWidth: 225,
forceSelection: true,
loadingText: 'Loading...',
triggerAction: 'all',
displayField: 'BRNAME',
valueField: 'BRBRKR',
tpl: brokerTpl,
itemSelector: 'div.ext-ux-transparent-message',
mode: 'local',
typeAhead: true,
store: new Ext.data.JsonStore({
autoLoad: true,
url: 'vvcall.pgm',
root: 'OSPBRKR',
fields: ['BRBRKR', 'BRNAME'],
baseParams: {
action: 'getBrokerCombo',
pgm: 'OSR1307'
}
})
}]

},{
items: [{
xtype: 'button',
width: 25,
iconCls: 'add',
style: 'padding-bottom:4px;',
handler: function(){
fnResetFields(addBrokerWindow);
addBrokerWindow.show();
}
}]
}, {
items: [{
layout: 'form',
items:[{
xtype: 'combo',
id: 'form_SalespersonCombo',
labelAlign: 'right',
fieldLabel: 'Sales Person',
width: 170,
listWidth: 225,
forceSelection: true,
loadingText: 'Loading...',
triggerAction: 'all',
displayField: 'SLNAME',
valueField: 'SLSLMN',
tpl: salespersonTpl,
itemSelector: 'div.ext-ux-transparent-message',
mode: 'local',
typeAhead: true,
store: new Ext.data.JsonStore({
autoLoad: true,
url: 'vvcall.pgm',
root: 'OSPSLMN',
fields: ['SLSLMN', 'SLNAME'],
baseParams: {
action: 'getSalespersonCombo',
pgm: 'OSR1308'
}
})
}]
}]
},{
items: [{
xtype: 'button',
width: 25,
iconCls: 'add',
style: 'padding-bottom:4px;',
handler: function(){
fnResetFields(addSalespersonWindow);
addSalespersonWindow.show();
}
}]

}]
});





// save a new sales person...
var fnSaveNewSalesperson = function(){
Ext.getBody().mask('<B>Attempting to save...</B>', 'x-msg-loading');
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
pgm: 'OSR1308',
action: 'addSalesperson',
form_SalespersonId: Ext.getCmp('form_SalespersonId').getValue(),
form_SalespersonName: Ext.getCmp('form_SalespersonName').getValue(),
form_SalespersonStreet: Ext.getCmp('form_SalespersonStreet').getValue(),
form_SalespersonBlock: Ext.getCmp('form_SalespersonBlock').getValue(),
form_SalespersonUnit: Ext.getCmp('form_SalespersonUnit').getValue(),
form_SalespersonCity: Ext.getCmp('form_SalespersonCity').getValue(),
form_SalespersonState: Ext.getCmp('form_SalespersonState').getValue(),
form_SalespersonCountry: Ext.getCmp('form_SalespersonCountry').getValue(),
form_SalespersonZip: Ext.getCmp('form_SalespersonZip').getValue(),
form_SalespersonPhone: Ext.getCmp('form_SalespersonPhone').getValue(),
form_SalespersonEmail: Ext.getCmp('form_SalespersonEmail').getValue()
},
success: function(response) {
var check = response.responseText;
if (check) {
var data = Ext.util.JSON.decode(response.responseText);
if (data.SUCCESS == '1') {
dsSalespersonCombo.reload();
addSalespersonWindow.hide();
parent.showMessage('Saved','New sales person has been added successfully');
Ext.getCmp('form_SalespersonCombo').setValue(Ext.g etCmp('form_SalespersonName').getValue());
//fnGetSalespersonDetails(Ext.getCmp('form_Salespers onId').getValue());
} else {
var fld = Ext.getCmp(data.FLD);
fld.focus();
fld.markInvalid(data.MSG);
if (data.ALLADDRESS == 'Y'){
Ext.getCmp('form_SalespersonStreet').markInvalid(' ');
Ext.getCmp('form_SalespersonBlock').markInvalid();
Ext.getCmp('form_SalespersonUnit').markInvalid();
Ext.getCmp('form_SalespersonCity').markInvalid();
Ext.getCmp('form_SalespersonState').markInvalid();
Ext.getCmp('form_SalespersonCountry').markInvalid( );
Ext.getCmp('form_SalespersonBlock').focus();
fld.markInvalid(data.MSG);
};
}
Ext.getBody().unmask();
};
},
failure: function(){
vvShowError('shipmententry_err001a', 'Received a failure response from the server when attempting to save a new customer.');
}
});
};

sean.lanktree
02-03-2010, 01:34 PM
Try changing the following line of code from...


mode: 'local',
typeAhead: true,
store: new Ext.data.JsonStore({
autoLoad: true,
url: 'vvcall.pgm',
root: 'OSPSLMN',
fields: ['SLSLMN', 'SLNAME'],
baseParams: {
action: 'getSalespersonCombo',
pgm: 'OSR1308'
}


To....


mode: 'remote',
typeAhead: true,
store: new Ext.data.JsonStore({
autoLoad: true,
url: 'vvcall.pgm',
root: 'OSPSLMN',
fields: ['SLSLMN', 'SLNAME'],
baseParams: {
action: 'getSalespersonCombo',
pgm: 'OSR1308'
}

naresh
02-03-2010, 04:53 PM
That worked, Thanks Sean.