PDA

View Full Version : Combo Boxes in Window fail to reload store



ArtBuilders
24 Mar 2010, 8:14 PM
Been using EXTJS since it was in beta. This may be my first time going to the community for help.

Issue: Combo boxes embedded in windows (with local stores) fail to reload after once selected, form saved and window is closed:

Combo code:


Ext.namespace('Ext.bugData');
//bug category combo
Ext.bugData.bugcategory = [
['admin-section', 'admin-section'],
['vendor-section', 'vendor-section']
];
Ext.ux.bugcategoryCombo = Ext.extend(Ext.form.ComboBox, {
initComponent:function() {
// call parent initComponent
Ext.ux.bugcategoryCombo.superclass.initComponent.call(this);
bugcategoryCombo = this;
} // end of function initComponent
});
Ext.reg('bugcategorycombo', Ext.ux.bugcategoryCombo);
//bug category combo eo

//bug type combo
Ext.bugData.bugtype = [
['failure', 'failure'],
['annoyance', 'annoyance'],
['inconsistency', 'inconsistency'],
['interface', 'interface']
];
Ext.ux.bugtypeCombo = Ext.extend(Ext.form.ComboBox, {
initComponent:function() {
// call parent initComponent
Ext.ux.bugtypeCombo.superclass.initComponent.call(this);
bugtypeCombo = this;
} // end of function initComponent
});
Ext.reg('bugtypecombo', Ext.ux.bugtypeCombo);
//bug type combo eo

//bug status combo
Ext.bugData.bugstatus = [
['new bug', 'new bug'],
['open', 'open'],
['assigned to developer', 'assigned to developer'],
['bug fix (waiting verification)', 'bug fix (waiting verification)'],
['closed (verified fixed)', 'closed (verified fixed)'],
['reopened', 'reopened'],
['suspended (fix later or not at all)', 'suspended (fix later or not at all)'],
['update (need more info)', 'update (need more info)']
];
Ext.ux.bugstatusCombo = Ext.extend(Ext.form.ComboBox, {
initComponent:function() {
// call parent initComponent
Ext.ux.bugstatusCombo.superclass.initComponent.call(this);
bugstatusCombo = this;
} // end of function initComponent
});
Ext.reg('bugstatuscombo', Ext.ux.bugstatusCombo);

//other combos excluded for brevity sake



Form code:


Ext.ns('BugForm');

BugForm.Form = Ext.extend(Ext.form.FormPanel, {
border:false,
frame:true,
autoScroll:true,
id:'bug-form',
name:'bug-form',

initComponent:function() {
// configure ourselves
Ext.apply(this, {
items: [{
labelAlign: 'top',
hideLabels:false,
frame:false,
bodyStyle: Ext.isIE ? 'padding:5px 5px 0' : 'padding:10px 15px;',
timeout : 30,
trackResetOnLoad : true,
waitMsgTarget: true,
items: [{
id:'bug-form_fld_1',
layout:'column',
/*title: 'Bug Information',*/
autoHeight:true,
items:[{
columnWidth:.5,

layout: 'form',
items: [{
xtype:'textfield',
name:'bug_title',
id:'bug_title',
fieldLabel:'Bug Title',
anchor:'90%',
tabIndex:1,
allowBlank:false
},{
xtype:'bugcategorycombo',
id:'bugcategory',
name:'bug_category',
fieldLabel:'Category',
typeAhead: true,
store: new Ext.data.SimpleStore({
fields: ['catid','name'],
data : Ext.bugData.bugcategory

}),
valueField:'catid',
displayField:'name',
hiddenValue:'bug_category',
editable: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Select bug category...',
selectOnFocus:true,
width:190,
tabIndex:2

},{
xtype:'bugassignedtocombo',
id:'bug_assigned_to',
name:'bug_assigned_to',
fieldLabel: 'Assign To',
typeAhead: true,
store: new Ext.data.SimpleStore({
fields: ['assid','name'],
data : Ext.bugData.bugassignedto

}),
valueField:'assid',
displayField:'name',
hiddenValue:'bug_assigned_to',
editable: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Assign bug to...',
selectOnFocus:true,
width:190,
tabIndex:2

},{

xtype:'bugprioritycombo',
id:'bug_priority',
name:'bug_priority',
fieldLabel: 'Priority',
typeAhead: true,
store: new Ext.data.SimpleStore({
fields: ['bug_priority','name'],
data : Ext.bugData.bugpriority

}),
valueField:'bug_priority',
displayField:'name',
hiddenValue:'bug_priority',
editable: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Select bug priroty...',
selectOnFocus:true,
width:190,
tabIndex:4

}]
},{
columnWidth:.5,
layout: 'form',
items: [{
xtype:'textfield',
name:'bug_reported_by',
id:'bugreported_by',
fieldLabel:'Bug Reported By',
anchor:'90%',
tabIndex:1
},{

xtype:'bugtypecombo',
id:'bugtype',
name:'bug_type',
fieldLabel: 'Type of Bug',
typeAhead: true,
store: new Ext.data.SimpleStore({
fields: ['typeid','name'],
data : Ext.bugData.bugtype

}),
valueField:'typeid',
displayField:'name',
hiddenValue:'bug_type',
editable: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Select bug type...',
selectOnFocus:true,
width:190,
tabIndex:3

},{
xtype:'bugstatuscombo',
id:'bugstatus',
name:'bug_status',
fieldLabel: 'Status',
typeAhead: true,
store: new Ext.data.SimpleStore({
fields: ['statusid','name'],
data : Ext.bugData.bugstatus

}),
valueField:'statusid',
displayField:'name',
hiddenValue:'bug_status',
editable: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Select bug status...',
selectOnFocus:true,
width:190,
tabIndex:5

}]
}]
},{
xtype:'htmleditor',
id:'bug_description',
name:'bug_description',
fieldLabel:'Description of Bug (with reproducable steps)',
tabIndex:8,
height: 'autoHeight',
//height:150,
anchor:'98%'
},{
xtype:'hidden',
id:'id',
name:'id',
hideLabels:true
},{
xtype:'hidden',
id:'bug_id',
name:'bug_id',
hideLabels:true
}]
}],
buttons: [{
text: 'Save',
formBind:true,
scope:this,
handler: function(scope) {

this.getForm().submit({
url:'/somedir/?c=form&m=updatebug',waitMsg:'Saving Data...',
method:'post', success:function(){
Ext.MessageBox.alert('Success!', 'The record has successfully been updated.');
bugWin.getComponent(0).getForm().reset();
bugWin.hide(); }});
}
},{
text: 'Close',
scope:this,
handler:function() {
bugWin.getComponent(0).getForm().reset();
bugWin.hide();
}
}]
}); // eo apply
BugForm.Form.superclass.initComponent.apply(this, arguments);

}, // eo function initComponent
onRender:function() {
// call parent
BugForm.Form.superclass.onRender.apply(this, arguments);
// set wait message target
this.getForm().waitMsgTarget = this.getEl();

}, // eo function onRender

onLoadClick:function() {
this.load({
url:this.url,
waitMsg:'Loading...',
params:{cmd:'load'}
});
// any additional load click processing here
}, // eo function onLoadClick

submit:function() {
this.getForm().submit({
url:this.url,
scope:this,
success:this.onSuccess,
failure:this.onFailure,
params:{cmd:'save'},
waitMsg:'Saving...'
});
},
onSuccess:function(form, action) {
Ext.Msg.show({
title:'Success',
msg:'Form submitted successfully',
modal:true,
icon:Ext.Msg.INFO,
buttons:Ext.Msg.OK
});
}, // eo function onSuccess
onFailure:function(form, action) {
this.showError(action.result.error || action.response.responseText);
}, // eo function onFailure
showError:function(msg, title) {
title = title || 'Error';
Ext.Msg.show({
title:title,
msg:msg,
modal:true,
icon:Ext.Msg.ERROR,
buttons:Ext.Msg.OK
});
} // eo function showError
}); // eo extend

// register xtype
Ext.reg('bugform', BugForm.Form);


And finally, the window code:



// application main entry point
var bugWin;
Ext.onReady(function() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
bugWin = new Ext.Window({
id:'bugform-window',
title:'Bug Account Form',
layout:'fit',
width:550,
height:500,
closeAction: 'hide',
closable:true,
border:false,
items:{id:'bugform-window-item', xtype:'bugform'}
});
//win.show();
}); // eo function onReady

// eof


Here's the PHP:


public function loadBug(){
//Headers are sent to prevent browsers from caching
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: application/json');
echo '{success:true, data:{';

$bug = new Bug($this->val['id']); //random id

echo '"bug_id": '.json_encode($bug->getBugID()).',';
echo '"id": '.json_encode($bug->getBugID()).',';
echo '"bug_title": '.json_encode($bug->getBugTitle()).',';
echo '"bug_type": '.json_encode($bug->getBugType()).',';
echo '"bug_description": '.json_encode($bug->getBugDescription()).',';
echo '"bug_category": '.json_encode($bug->getBugCategory()).',';
echo '"bug_assigned_to": '.json_encode($bug->getBugAssignedTo()).',';
echo '"bug_reported_by": '.json_encode($bug->getBugReportedBy()).',';
echo '"bug_priority": '.json_encode($bug->getBugPriority()).',';
echo '"bug_status": '.json_encode($bug->getBugStatus()).',';
echo '"bug_followup": '.json_encode($bug->getBugFollowup()).' ';
echo '}}';

exit();
}

This is a very large app with many forms & windows. I've spent most of the day trying to resolve. Seems it disappears and then re-appears in some case (though consistent in others). Any help would be appreciated.