jeudi 29 mai 2014

How can I clear the data from a second combo of a linked combobox pair after changing

I have 2 comboboxes which are linked. The data store of the first combo box remains constant, but the data store of the second combo box changes depending on the data selected in the first combo box.

Fairly straight forward so far:

Select Disease Combo box



Code:



Ext.define("COMS.view.Common.selDisease" ,{
extend: "Ext.form.field.ComboBox",
alias : "widget.selDisease",
name : "selDisease",
store : "DiseaseType",
emptyText : "Select a Cancer Type",
allowBlank: false,
width: 500,
size : 50,
labelWidth: 160,
fieldLabel: "Select a type of cancer <em>*</em>",
labelAlign: "right",

displayField: "name",
valueField: "id"
});



Select DiseaseStage Combo box

Code:



Ext.define("COMS.view.Common.selDiseaseStage" ,{
extend: "Ext.form.field.ComboBox",
alias : "widget.selDiseaseStage",
name : "Select Disease Stage Control",
store : "DiseaseStage",
emptyText : "Select a Cancer Stage",
allowBlank: false,
width: 250,
size : 10,
labelWidth: 90,
fieldLabel: "Cancer Stage",
labelAlign: "right",

displayField: "Stage",
valueField: "ID"
});

Event Handlers

Code:



onDiseaseSelected: function (combo, recs, eOpts) {
this.application.Cancer = recs[0].data;
var stage = this.getDiseaseStage();
var stageStore = stage.getStore();
stageStore.removeAll();

stageStore.load({
scope : this,
params : {
URL : Ext.URLs.DiseaseStage + "/",
ID : this.application.Cancer.id
}
});
},

onDiseaseStageChange: function (combo, recs, eOpts) {
this.application.Cancer.Stage = recs[0].data;
}

Now, if I select "Appendix Cancer" in the Disease combo box my selectable values for the Disease Stage combo box are as follows:

DiseaseStage Store for Appendix Cancer Data:



Code:



Value: "Stage 1", ID : "S1a"
Value: "Stage 2", ID : "S2a"
Value: "Stage 3", ID : "S3a"
Value: "Stage 4", ID : "S4a"

So if I select "Stage 1" for my disease stage in my second combo box the "value" of the field is "S1a" (but the combo displays "Stage 1").

All good so far.

Now, if I go back and select "Colon Cancer" in the Disease combo box, a different data set is loaded into the store:



Code:



Value: "Stage Alpha", ID : "S1b"
Value: "Stage Beta", ID : "S2b"
Value: "Stage Gamma", ID : "S3b"
Value: "Stage Epsilon", ID : "S4b"

Note that there is no matching value for an ID of "S1a" which was the value from the initial selection.

I see "S1a" in the Disease Stage combo box before I even have the chance to make a selection.

HOW do I prevent the disease stage combo from displaying the ID value from the previously store and display the "emptyText" configured for the combo box?


I've tried so many various combinations of clearValue(), setValue(""), reset(), resetOriginalValue(), resetOriginalValue(), bindStore(null), etc that I have just run out of methods on the combobox to call! .


Thanks in advance

MikeB





Aucun commentaire:

Enregistrer un commentaire