PDA

View Full Version : problem loading form using direct



isit.gd
16 Oct 2009, 8:03 AM
hey

i'm trying to load a form using direct - here is my js (simplest demo version):



Ext.ns('Ideal.ReportDesigner.ReportEditor');

Ideal.ReportDesigner.ReportEditor = Ext.extend(Ext.form.FormPanel, {
title: 'Form Test Panel',
frame: true,
bodyStyle: {
backgroundColor: '#ffffff',
border: 'solid 1px #99BBE8',
padding: '5px'
},

initComponent: function() {
var config = {
api: {
load: DirectReportDesigner.GetReport,
submit: DirectReportDesigner.UpdateReport
},

items: [{
name: 'id',
xtype: 'hidden',
value: 100
}, {
name: 'title',
xtype: 'textfield',
fieldLabel: 'Name',
anchor: '0'
}
],

buttons: [{
text: 'Load',
handler: function() {
this.getForm().load();
},
scope: this
}
],
tools: [{
id: 'refresh',
qtip: 'Reset the form',
handler: function() {
this.getForm().reset();
},
scope: this
}
]
};

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

Ideal.ReportDesigner.ReportEditor.superclass.initComponent.call(this);
}
});

Ext.reg('reportEditorForm', Ideal.ReportDesigner.ReportEditor);




and on the server - i'm using .net - i have the following:



public DirectResult GetReport()
{
var report = Repository.Get(3);

var result = new
{
success = true,
data = report
};

return Direct(result);

}



everything works fine.

now - i dont want to hard code the id of the report to load so i want to pass it as a parameter in the load call:



handler: function() {
this.getForm().load({
params: {
reportid: rid
}
});
}


and on the server:



public DirectResult GetReport(int reportid)
{
var report = Repository.Get(reportid);

var result = new
{
success = true,
data = report
};

return Direct(result);

}


however - when i add this reportid into the mix it starts throwing js errors:

line 58861 of ext-all-debug.js:



// default connection failure
failure : function(response){
this.response = response;
this.failureType = Ext.form.Action.CONNECT_FAILURE;
this.form.afterAction(this, false);
},



there isn't any info anywhere as to why it fails - but i know it doesn't get as far as calling the method on the server.

am i doing something wrong here?

w://

isit.gd
16 Oct 2009, 8:54 AM
i managed to get this working - looks like you need to have the


paramOrder: ['reportid']

included in the form :s

w://