-
15 Feb 2010 10:37 PM #1
standardSubmit issue
standardSubmit issue
Hi,
I currently have a formpanel which contains some fields that I use to search, the search results are then put into a gridpanel. I am now trying to add an export button, but since you can't get a csv export from a standard submit I am trying to create a hiden formpanel which I will fill with the search params and query the server. To do this I believe I need to use the standardSubmit options but I can get the examples to work eg: http://www.extjs.com/learn/Manual:Fo...standardSubmit .
This is my code, it is a direct copy and paste from the example but I can't get it to submit and it just throws and error ( the error is listed at the bottom ).
And I call it from the other formpanel by doingCode:var exportForm = new Ext.FormPanel({ renderTo: document.body, labelAlign: "side", frame: true, autoHeight: true, waitMsgTarget: true, standardSubmit: true, baseParams: { id: 1 }, url: "myProcess.php", title: "My Form", items: [{ title: "Name Fields", xtype: "fieldset", autoHeight: true, defaults: { hideLabel: true, labelSeparator: "" }, items: { xtype: "textfield", name: "userName" } }], buttons: [{ text: "Save", id: 'hidden_button', handler: function () { var O = this.ownerCt; if (O.getForm().isValid()) { if (O.url) O.getForm().getEl().dom.action = O.url; if (O.baseParams) { for (i in O.baseParams) { O.add({ xtype: "hidden", name: i, value: O.baseParams[i] }) } O.doLayout(); } O.getForm().submit(); } } }] });
However firebug is giving me the error:Code:Ext.getCmp('hidden_button').handler();
help please ?Code:O.getForm is not a function
I am using v3.1.1
-
15 Feb 2010 11:00 PM #2
-
15 Feb 2010 11:41 PM #3
Dammit, I should of been able to combine the broken code of http://www.extjs.com/deploy/dev/docs...form.BasicForm with the broken code of http://www.extjs.com/learn/Manual:Fo...standardSubmit to get it working
.
Thanks for the help.
-
15 Feb 2010 11:57 PM #4
There is a bug in standartSubmit example.

-
16 Feb 2010 6:15 PM #5
Here is my solution, probably not the best, hopefully it will help someone else.
And I just call it from a button on the formpanel like so:Code:var exportForm = new Ext.FormPanel({ renderTo: document.body, // This is required, wouldn't work without standardSubmit: true, baseParams: {}, url: 'exportUrl', buttons: [{ id: 'hidden_button', handler: function () { var form = this.ownerCt.ownerCt; if (form.getForm().isValid()) { if (form.url) form.getForm().getEl().dom.action = form.url; if (form.baseParams) { // searchPanel is my panel with all the formfields. searchPanel.form.items.each(function(){ form.add({ xtype: 'hidden', name: this.getName(), value: this.getValue() }); }); form.doLayout(); } form.getForm().submit(); } } }] });
Code:Ext.getCmp('hidden_button').handler();
-
17 Feb 2010 12:51 AM #6
I don't understand why you don't just make an Ajax request?
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
17 Feb 2010 12:58 AM #7
-
17 Feb 2010 1:57 AM #8
-
17 Feb 2010 2:13 AM #9
OK, if you need to submit something and receive a file, then submitting a form is the correct way.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
17 Feb 2010 5:44 AM #10


Reply With Quote

