PDA

View Full Version : autoLoad in Formpanel destroys FormPanel? Weird behavior...



alexpetri
15 Jul 2010, 8:58 AM
Hi,

i would like to have a formpanel with autoloaded data
so i changed the example on http://www.sencha.com/deploy/dev/examples/form/xml-form.html
and added the autoLoad option
and put it into Firebug Console - the results are weird.
Whats wrong there?


var fs = new Ext.FormPanel({
frame: true,
title:'XML Form New',
labelAlign: 'right',
labelWidth: 85,
width:340,
waitMsgTarget: true,
autoLoad::'xml-form.xml',
// configure how to read the XML Data
reader : new Ext.data.XmlReader({
record : 'contact',
success: '@success'
}, [
{name: 'first', mapping:'name/first'}, // custom mapping
{name: 'last', mapping:'name/last'},
'company', 'email', 'state',
{name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
]),

// reusable eror reader class defined at the end of this file
errorReader: new Ext.form.XmlErrorReader(),

items: [
new Ext.form.FieldSet({
title: 'Contact Information',
autoHeight: true,
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
emptyText: 'First Name',
name: 'first',
width:190
}, {
fieldLabel: 'Last Name',
emptyText: 'Last Name',
name: 'last',
width:190
}, {
fieldLabel: 'Company',
name: 'company',
width:190
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email',
width:190
},

new Ext.form.ComboBox({
fieldLabel: 'State',
hiddenName:'state',
store: new Ext.data.ArrayStore({
fields: ['abbr', 'state'],
data : Ext.exampledata.states // from states.js
}),
valueField:'abbr',
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
width:190
}),

new Ext.form.DateField({
fieldLabel: 'Date of Birth',
name: 'dob',
width:190,
allowBlank:false
})
]
})
]
});

// simple button add
fs.addButton('Load', function(){
fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});
});

// explicit add
var submit = fs.addButton({
text: 'Submit',
disabled:true,
handler: function(){
fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...', submitEmptyText: false});
}
});

fs.render('form-ct');

fs.on({
actioncomplete: function(form, action){
if(action.type == 'load'){
submit.enable();
}
}
});

});

Animal
15 Jul 2010, 9:17 AM
Why weird? dumping a block of XML into the innerHTML of a Panel's body is ever going to be pretty!