deejam
22 Jan 2009, 8:20 AM
Hello!
I found this excellent framework a couple of days ago and I find it very useful despite that I have never developed i JavaScript before.
I'm learning by trial-and-error and I do solve my problems after searching this forum, google etc but I'm stuck on a problem that I think I know the reason for, but not how to solve it. I've find lots of similar problems but I have not been able to use that knowledge to fix my problem.
My problem
I have a FormPanel with a tbar of fields and a htmlarea as items. When data is loaded it will be assigned to the htmlarea, but not the fields inside the tbar. If I move a field from the tbar outside the tbar (like the htmlarea), it will work fine. Saving is no problem, all values from the tbar will submit like a charm!
I'm having trouble understanding in which way events are launched (for example render).
My testing code
Ext.msp.articleEditorForm = Ext.extend(Ext.form.FormPanel, {
frame: true,
width: 600,
labelWidth: 70,
method: 'POST',
reader: new Ext.data.JsonReader({
fields: ['id', 'headline', 'created_date', 'publish_date', 'publish', 'content' ],
root: 'data'
}),
initComponent:function() {
Ext.apply(this, {
items: [{
// Fields within tbar do not load
// but saves fine
tbar: [{
xtype: 'textfield',
name: 'headline',
},'-',{
xtype: 'datefield',
name: 'publish_date',
format: 'Y-m-d'
},{
xtype:'timefield',
name: 'publish_time',
format: 'H:i',
increment: 30,
width: 100,
},'->',{
xtype:'checkbox',
name: 'publish',
boxLabel: 'Publish'
}]
// First level fields do load
},{
xtype: 'hidden',
fieldLabel: 'id',
name: 'id',
},{
xtype: 'textfield',
name: 'headline',
},{
xtype: 'htmleditor',
name: 'content',
hideLabel: true,
labelSeparator: '',
height: 500,
anchor: '100%'
}],
buttons:[{
text: 'Save',
formBind: true,
scope: this,
handler: this.onSubmit
}]
});
Ext.msp.articleEditorForm.superclass.initComponent.apply(this, arguments);
},
onRender:function() {
Ext.msp.articleEditorForm.superclass.onRender.apply(this, arguments);
},
onSubmit:function() {
this.getForm().submit({
url: 'url_removed',
scope: this,
//success:this.onSuccess,
//failure:this.onFailure,
/*params: {
id:'save'
},*/
//waitMsg:'Saving...',
});
},
});
Ext.reg('articleEditorForm', Ext.msp.articleEditorForm);
function newArticleEditorForm ( articleId ) {
test = new Ext.msp.articleEditorForm;
test.load ({
url: 'url_removed',
});
// Returns to a window, not shown in this example
return test;
}
I found this excellent framework a couple of days ago and I find it very useful despite that I have never developed i JavaScript before.
I'm learning by trial-and-error and I do solve my problems after searching this forum, google etc but I'm stuck on a problem that I think I know the reason for, but not how to solve it. I've find lots of similar problems but I have not been able to use that knowledge to fix my problem.
My problem
I have a FormPanel with a tbar of fields and a htmlarea as items. When data is loaded it will be assigned to the htmlarea, but not the fields inside the tbar. If I move a field from the tbar outside the tbar (like the htmlarea), it will work fine. Saving is no problem, all values from the tbar will submit like a charm!
I'm having trouble understanding in which way events are launched (for example render).
My testing code
Ext.msp.articleEditorForm = Ext.extend(Ext.form.FormPanel, {
frame: true,
width: 600,
labelWidth: 70,
method: 'POST',
reader: new Ext.data.JsonReader({
fields: ['id', 'headline', 'created_date', 'publish_date', 'publish', 'content' ],
root: 'data'
}),
initComponent:function() {
Ext.apply(this, {
items: [{
// Fields within tbar do not load
// but saves fine
tbar: [{
xtype: 'textfield',
name: 'headline',
},'-',{
xtype: 'datefield',
name: 'publish_date',
format: 'Y-m-d'
},{
xtype:'timefield',
name: 'publish_time',
format: 'H:i',
increment: 30,
width: 100,
},'->',{
xtype:'checkbox',
name: 'publish',
boxLabel: 'Publish'
}]
// First level fields do load
},{
xtype: 'hidden',
fieldLabel: 'id',
name: 'id',
},{
xtype: 'textfield',
name: 'headline',
},{
xtype: 'htmleditor',
name: 'content',
hideLabel: true,
labelSeparator: '',
height: 500,
anchor: '100%'
}],
buttons:[{
text: 'Save',
formBind: true,
scope: this,
handler: this.onSubmit
}]
});
Ext.msp.articleEditorForm.superclass.initComponent.apply(this, arguments);
},
onRender:function() {
Ext.msp.articleEditorForm.superclass.onRender.apply(this, arguments);
},
onSubmit:function() {
this.getForm().submit({
url: 'url_removed',
scope: this,
//success:this.onSuccess,
//failure:this.onFailure,
/*params: {
id:'save'
},*/
//waitMsg:'Saving...',
});
},
});
Ext.reg('articleEditorForm', Ext.msp.articleEditorForm);
function newArticleEditorForm ( articleId ) {
test = new Ext.msp.articleEditorForm;
test.load ({
url: 'url_removed',
});
// Returns to a window, not shown in this example
return test;
}