PDA

View Full Version : Checkboxes & form.load()



Crestien
17 Aug 2011, 1:06 PM
I'm working on a fairly complicated program and I've run into a brick wall. I auto generate checkboxes based on the student you choose. viewport.dailyTreatmentListEdit is an Ext.form.FormPanel that's created earlier in the script.


// Create The Form
viewport.dailyTreatmentListEdit.add([{
xtype: 'fieldset',
title: 'IEP Goals',
defaults: {
labelAlign: 'left',
labelWidth: '30%'
},
items: [{
xtype: 'hiddenfield',
name : 'id'
}, {
xtype: 'hiddenfield',
name : 'student_id'
}, {
xtype: 'datepickerfield',
name : 'date',
label: 'Date',
picker: { yearFrom: 2011 }
}
]}
]);

if(record.data.iep1) {
viewport.dailyTreatmentListEdit.add([
{
xtype: 'checkboxfield',
name: 'iep1',
label: record.data.iep1,
value: 'Yes'
}
]);
}
if(record.data.iep2) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep2',
label: record.data.iep2,
value: 'Yes'
}
]);
}
if(record.data.iep3) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep3',
label: record.data.iep3,
value: 'Yes'
}
]);
}
if(record.data.iep4) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep4',
label: record.data.iep4,
value: 'Yes'
}
]);
}
if(record.data.iep5) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep5',
label: record.data.iep5,
value: 'Yes'
}
]);
}
if(record.data.iep6) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep6',
label: record.data.iep6,
value: 'Yes'
}
]);
}
if(record.data.iep7) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep7',
label: record.data.iep7,
value: 'Yes'
}
]);
}
if(record.data.iep8) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep8',
label: record.data.iep8,
value: 'Yes'
}
]);
}
if(record.data.iep9) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep9',
label: record.data.iep9,
value: 'Yes'
}
]);
}
if(record.data.iep10) {
viewport.dailyTreatmentListEdit.add([{
xtype: 'checkboxfield',
name: 'iep10',
label: record.data.iep10,
value: 'Yes'
}
]);
}
viewport.dailyTreatmentListEdit.doLayout();


I have a list of previous Daily Treatments for the chosen student. When you choose something from that list it uses loadRecord() in the handler to auto-fill the subsequent form that is then set as the activeItem.



var dailyTreatmentList = viewport.dailyTreatmentList = new Ext.List({
id: 'dailytreatmentlist',
store: wn.DailyTreatmentStore,
itemTpl: '<div class="student">{date}, {student_id}</div>',
onItemDisclosure: function(record, btn, index) {
dailyTreatmentListEdit.loadRecord(Ext.ModelMgr.create({
'id' : record.data.id,
'student_id': record.data.student_id,
'date' : record.data.date,
'iep1' : record.data.iep1,
'iep2' : record.data.iep2,
'iep3' : record.data.iep3,
'iep4' : record.data.iep4,
'iep5' : record.data.iep5,
'iep6' : record.data.iep6,
'iep7' : record.data.iep7,
'iep8' : record.data.iep8,
'iep9' : record.data.iep9,
'iep10' : record.data.iep10
}, 'DailyTreatment'));
viewport.dailyTreatmentListPanel.setActiveItem('dailytreatmentedit');
}
});


This works perfectly on many of the other forms I use, however on this form I have checkboxes and they never get checked. I've searched Google, these forums, and stackoverflow and I just don't see where this problem has been addressed.

I've verified through alert() that record.data.iep1 = 'Yes' in the code directly above, which is the value I have assigned to the checkbox named iep1 in the first back of code.

Any help would be GREATLY appreciated.

Crestien
17 Aug 2011, 2:06 PM
I just changed the value of all the checkbox fields from 'Yes' to just use true/false boolean options and everything started working across the board. I guess that's what I'll use from now on with checkboxes.

Thanks anyways!