PDA

View Full Version : data not displayed in text area and checkbox



imedx01
23 Dec 2009, 10:21 PM
Above is the code for display values from json array,values are getting populated properly in json array but not display values in check box and text area,name is same as in json array and ext-js component but we are able to display value only for stomachIntestinalProblems1,please let me know if any issue with code .its urgent!!!!!!!!!!



var medicalHistoryProxy=new Ext.data.HttpProxy(
{
url :'RetrieveMedicalHistory.do'
});

//To create an Array of Ext.data.Record
//objects from a JSON packet
//
var medicalHistoryReader=new Ext.data.JsonReader(
{
},
// the fields config option will internally create an Ext.data.Record
// it provides mapping for reading the record from data objects
[
// map Record's 'appeId' field to data object's key of same name
{
name:'diabetes'
},
{
name:'hypertension'
},
{
name:'thyroidProblems'
},
{
name:'heartDisease'
},
{
name:'respiratoryProblems'
},
{
name:'bleedingDisorder'
},
{
name:'melanoma'
},
{
name:'stomachIntestinalProblems1'
},
{
name:'allergyProblemsTherapy'
},
{
name:'kidneyProblems'
},
{
name:'otherMedicalProblems'
},
{
name:'neurologicalProblems'
},
{
name:'skinCancer'
},
{
name:'mhDiabetes'
},
{
name:'mhHypertension'
},
{
name:'mhThyroidproblems'
},
{
name:'mhHeart'
},
{
name:'mhRespiratory'
},
{
name:'mhBleeding'
},
{
name:'mhMelanoma'
},
{
name:'mhStomach'
},
{
name:'mhAllergy'
},
{
name:'mhKidney'
},
{
name:'mhNeurological'
},
{
name:'mhOtherMedical'
},
{
name:'mhSkinCancer'
},


{
name:'medicalHistroyId'
}
]);
var medicalHistoryStore=new Ext.data.Store({

proxy:medicalHistoryProxy,
reader:medicalHistoryReader

});

medicalHistoryStore.on('load',function()
{


if(document.getElementById('medicalHistroyId') !== null && medicalHistoryStore.getAt(0).data.medicalHistroyId !== undefined)
{

document.getElementById('medicalHistroyId').value=medicalHistoryStore.getAt(0).data.medicalHistroyId;
}

if(document.getElementById("Diabetes") !== null && medicalHistoryStore.getAt(0).data.diabetes !== undefined)
{

document.getElementById("Diabetes").checked=medicalHistoryStore.getAt(0).data.diabetes;
}

if(document.getElementById('hypertension') !== null && medicalHistoryStore.getAt(0).data.hypertension !== undefined)
{
document.getElementById('hypertension').checked=medicalHistoryStore.getAt(0).data.hypertension;
}

if(document.getElementById("thyroidProblems") !== null && medicalHistoryStore.getAt(0).data.thyroidProblems !== undefined)
{
document.getElementById('thyroidProblems').checked=medicalHistoryStore.getAt(0).data.thyroidProblems;
}

if(document.getElementById('heartDisease')!== null && medicalHistoryStore.getAt(0).data.heartDisease !== undefined)
{
document.getElementById('heartDisease').checked=medicalHistoryStore.getAt(0).data.heartDisease;
}

if(document.getElementById('respiratoryProblems') !== null && medicalHistoryStore.getAt(0).data.respiratoryProblems !== undefined)
{
document.getElementById('respiratoryProblems').checked=medicalHistoryStore.getAt(0).data.respiratoryProblems;
}


if(document.getElementById('bleedingDisorder') !== null && medicalHistoryStore.getAt(0).data.bleedingDisorder !== undefined)
{
document.getElementById('bleedingDisorder').checked=medicalHistoryStore.getAt(0).data.bleedingDisorder;
}

if(document.getElementById('melanoma') !== null && medicalHistoryStore.getAt(0).data.melanoma !== undefined)
{
document.getElementById('melanoma').checked=medicalHistoryStore.getAt(0).data.melanoma;
}

if(document.getElementById("mhDiabetes") !== null && medicalHistoryStore.getAt(0).data.mhDiabetes !== undefined)
{
document.getElementById("mhDiabetes").value=medicalHistoryStore.getAt(0).data.mhDiabetes;
}

if(document.getElementById('mhHypertension') !== null && medicalHistoryStore.getAt(0).data.mhHypertension !== undefined)
{
document.getElementById('mhHypertension').value=medicalHistoryStore.getAt(0).data.mhHypertension;
}

if(document.getElementById('mhThyroidproblems') !== null && medicalHistoryStore.getAt(0).data.mhThyroidproblems !== undefined)
{
document.getElementById('mhThyroidproblems').value=medicalHistoryStore.getAt(0).data.mhThyroidproblems;
}

if(document.getElementById('mhHeart') !== null && medicalHistoryStore.getAt(0).data.mhHeart !== undefined)
{
document.getElementById('mhHeart').value=medicalHistoryStore.getAt(0).data.mhHeart;
}

if(document.getElementById('mhRespiratory') !== null && medicalHistoryStore.getAt(0).data.mhRespiratory !== undefined)
{
document.getElementById('mhRespiratory').value=medicalHistoryStore.getAt(0).data.mhRespiratory;
}

if(document.getElementById('mhBleeding') !== null && medicalHistoryStore.getAt(0).data.mhBleeding !== undefined)
{
document.getElementById('mhBleeding').value=medicalHistoryStore.getAt(0).data.mhBleeding;
}

if(document.getElementById('mhMelanoma') !== null && medicalHistoryStore.getAt(0).data.mhMelanoma !== undefined)
{
document.getElementById('mhMelanoma').value=medicalHistoryStore.getAt(0).data.mhMelanoma;
}

if(document.getElementById('stomachIntestinalProblems1') !== null && medicalHistoryStore.getAt(0).data.stomachIntestinalProblems1 !== undefined)
{
document.getElementById('stomachIntestinalProblems1').checked=medicalHistoryStore.getAt(0).data.stomachIntestinalProblems1;
}
if(document.getElementById('allergyProblemsTherapy') !== null && medicalHistoryStore.getAt(0).data.allergyProblemsTherapy !== undefined)
{
document.getElementById('allergyProblemsTherapy').checked=medicalHistoryStore.getAt(0).data.allergyProblemsTherapy;
}
if(document.getElementById('kidneyProblems') !== null && medicalHistoryStore.getAt(0).data.kidneyProblems !== undefined)
{
document.getElementById('kidneyProblems').checked=medicalHistoryStore.getAt(0).data.kidneyProblems;
}
if(document.getElementById('otherMedicalProblems') !== null && medicalHistoryStore.getAt(0).data.otherMedicalProblems !== undefined)
{
document.getElementById('otherMedicalProblems').checked=medicalHistoryStore.getAt(0).data.otherMedicalProblems;
}
if(document.getElementById('neurologicalProblems') !== null && medicalHistoryStore.getAt(0).data.neurologicalProblems !== undefined)
{
document.getElementById('neurologicalProblems').checked=medicalHistoryStore.getAt(0).data.neurologicalProblems;
}
if(document.getElementById('skinCancer') !== null && medicalHistoryStore.getAt(0).data.skinCancer !== undefined)
{
document.getElementById('skinCancer').checked=medicalHistoryStore.getAt(0).data.skinCancer;
}
if(document.getElementById('mhStomach') !== null && medicalHistoryStore.getAt(0).data.mhStomach !== undefined)
{
document.getElementById('mhStomach').value=medicalHistoryStore.getAt(0).data.mhStomach;
}
if(document.getElementById('mhAllergy') !== null && medicalHistoryStore.getAt(0).data.mhAllergy !== undefined)
{
document.getElementById('mhAllergy').value=medicalHistoryStore.getAt(0).data.mhAllergy;
}
if(document.getElementById('mhKidney') !== null && medicalHistoryStore.getAt(0).data.mhKidney !== undefined)
{
document.getElementById('mhKidney').value=medicalHistoryStore.getAt(0).data.mhKidney;
}
if(document.getElementById('mhNeurological') !== null && medicalHistoryStore.getAt(0).data.mhNeurological !== undefined)
{
document.getElementById('mhNeurological').value=medicalHistoryStore.getAt(0).data.mhNeurological;
}
if(document.getElementById('mhOtherMedical') !== null && medicalHistoryStore.getAt(0).data.mhOtherMedical !== undefined)
{
document.getElementById('mhOtherMedical').value=medicalHistoryStore.getAt(0).data.mhOtherMedical;
}
if(document.getElementById('mhSkinCancer') !== null && medicalHistoryStore.getAt(0).data.mhSkinCancer !== undefined)
{
document.getElementById('mhSkinCancer').value=medicalHistoryStore.getAt(0).data.mhSkinCancer;
}
});
Ext.ns('PostLoginPage');
PostLoginPage.MedicalHistoryForm = Ext.extend(Ext.form.FormPanel, {

id:'medicalHistoryForm',
xtype:'form',
layout:'form',
title:'Medical History',
frame:false,
labelWidth:100,
border:false,
// these are applied to columns

initComponent:function() {

var config = {

xtype:'form',
layout:'form',
region:'center',
frame:false,
border:false,
// bounding form
items:[
{
xtype:'panel',
layout:'column',
frame:false,
labelWidth:1,
height:500,
defaults:
{
layout:'column',
hideLabels:true,
border:false,
bodyStyle:'padding:4px'
},
// columns for ist set of check box
items:[{
// these are applied to fieldsets

defaults:
{
layout:'form',
anchor:'100%',
autoHeight:true
},

items:[
{
defaultType:'fieldset',
defaults:{
anchor:'100%'
},
items:[
{
xtype : 'checkbox',
name: 'diabetes',
boxLabel : 'Diabetes',
id:'Diabetes',
height:60,



checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhDiabetes").setDisabled(false);
}
else
{
Ext.getCmp("mhDiabetes").setDisabled(true);

}
}
}
}
},
{
xtype : 'checkbox',
name: 'hypertension',
boxLabel : 'Hypertension',
id:'hypertension',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhHypertension").setDisabled(false);

}
else{
Ext.getCmp("mhHypertension").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'thyroidProblems',
boxLabel : 'Thyroid Problems',
id:'thyroidProblems',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhThyroidproblems").setDisabled(false);

}
else{
Ext.getCmp("mhThyroidproblems").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'heartDisease',
boxLabel : 'Heart Disease/Choletrol',
id:'heartDisease',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhHeart").setDisabled(false);

}
else{
Ext.getCmp("mhHeart").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'respiratoryProblems',
boxLabel : 'Respiratory Problems',
id:'respiratoryProblems',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhRespiratory").setDisabled(false);

}
else{
Ext.getCmp("mhRespiratory").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'bleedingDisorder',
boxLabel : 'Bleeding Disorder',
id:'bleedingDisorder',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhBleeding").setDisabled(false);

}
else{
Ext.getCmp("mhBleeding").setDisabled(true);
}}
}
}
},
{
xtype : 'checkbox',
name: 'melanoma',
boxLabel : 'Melanoma',
id:'melanoma',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhMelanoma").setDisabled(false);

}
else{
Ext.getCmp("mhMelanoma").setDisabled(true);
}
}
}
}
},
{
xtype : 'hidden',
name: 'medicalHistroyId',
id:'medicalHistroyId'
}
]
}]
},{


// these are applied to fieldsets
defaults:{
xtype:'fieldset',
layout:'form',
anchor:'100%',
labelWidth:5,
border:false
},

// fieldsets

items:[{
defaultType:'fieldset',
defaults:{
anchor:'100%'
},
items:[
{
xtype: 'textarea',
name: 'mhDiabetes',
id:'mhDiabetes',
style:{overflow:'scroll'},
height:60,
width:200

},

{
xtype: 'textarea',
name: 'mhHypertension',
id:'mhHypertension',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhThyroidproblems',
id:'mhThyroidproblems',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhHeart',
id:'mhHeart',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhRespiratory',
id:'mhRespiratory',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhBleeding',
id:'mhBleeding',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhMelanoma',
id:'mhMelanoma',
style:{overflow:'scroll'},
height:60,
width:200
}
]
}]

},
{
defaults:
{
layout:'form',
anchor:'100%',
autoHeight:true

},

items:[
{
defaultType:'fieldset',
defaults:{
anchor:'100%'
},
items:[
{
xtype : 'checkbox',
name: 'stomachIntestinalProblems1',
boxLabel : 'Stomach or Intestinal Problems ',
id:'stomachIntestinalProblems1',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhStomach").setDisabled(false);

}
else{
Ext.getCmp("mhStomach").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'allergyProblemsTherapy',
boxLabel : 'Allergy Problems/therapy',
id:'allergyProblemsTherapy',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhAllergy").setDisabled(false);
}
else{
Ext.getCmp("mhAllergy").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'kidneyProblems',
boxLabel : 'Kidney Problems',
id:'kidneyProblems',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhKidney").setDisabled(false);

}
else{
Ext.getCmp("mhKidney").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'neurologicalProblems',
boxLabel : 'Neurological Problems',
id:'neurologicalProblems',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhNeurological").setDisabled(false);

}
else{
Ext.getCmp("mhNeurological").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'otherMedicalProblems',
boxLabel : 'Other Medical Problems',
id:'otherMedicalProblems',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhOtherMedical").setDisabled(false);

}
else{
Ext.getCmp("mhOtherMedical").setDisabled(true);
}
}
}
}
},
{
xtype : 'checkbox',
name: 'skinCancer',
boxLabel : 'Skin Cancer',
id:'skinCancer',
height:60,
checked : false,listeners:
{
check :
{
fn: function(checkbox, checked)
{
if(checked)
{
Ext.getCmp("mhSkinCancer").setDisabled(false);

}
else{
Ext.getCmp("mhSkinCancer").setDisabled(true);
}
}
}
}
}
]


}
]
},

{
// these are applied to fieldsets
defaults:{
xtype:'fieldset',
layout:'form',
anchor:'100%',
autoHeight:true,
labelWidth:5,
border:false
},

// fieldsets

items:[{
defaultType:'fieldset',
defaults:{
anchor:'100%'
},
items:[
{
xtype: 'textarea',
name: 'mhStomach',
id:'mhStomach',
dataIndex:'mhStomach',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhAllergy',
id:'mhAllergy',
style:{overflow:'scroll'},
height:60,
width:200
},

{
xtype: 'textarea',
name: 'mhKidney',
id:'mhKidney',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhNeurological',
id:'mhNeurological',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhOtherMedical',
id:'mhOtherMedical',
style:{overflow:'scroll'},
height:60,
width:200
},
{
xtype: 'textarea',
name: 'mhSkinCancer',
id:'mhSkinCancer',
style:{overflow:'scroll'},
height:60,
width:200
}
]
}]

}
]

}

],
buttons: [
{
text: 'Save',
scope:this,
handler:this.submit,
formBind:true
},
{
text: 'Cancel',
scope:this
// handler:this.onLoadClick,
}]

}; // eo config object

// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));

// call parent
PostLoginPage.MedicalHistoryForm.superclass.initComponent.apply(this, arguments);

},
onRender:function()
{
PostLoginPage.MedicalHistoryForm.superclass.onRender.apply(this, arguments);

// set wait message target
this.getForm().waitMsgTarget = this.getEl();

},
submit:function()
{
this.getForm().getEl().dom.action = 'MedicalHistory.do';
this.getForm().getEl().dom.method = 'POST';
this.getForm().submit({
url:'MedicalHistory.do',
scope:this,
success:this.onSuccess,
failure:this.onFailure,
params:{patientId:patientId}
//,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 extend

// register xtype
Ext.reg('medicalHistoryForm', PostLoginPage.MedicalHistoryForm);

Condor
24 Dec 2009, 12:47 AM
Do NOT use:

document.getElementById('id-of-element').value = ...;

Instead use:

Ext.getCmp('id-of-field').setValue(...);