+ },
+ /* not used as it didn't work..
+ onLoad : function()
+ {
+ // requested++; // second request is real one..
+ // if (requested < 2) {
+ // return;
+ //} // n
+ Roo.log('onload?');
+ if (!this.submit) {
+ return false;
+ }
+ //return false;
+
+ var frame = this.csvFrame;
+ var success = true;
+ try {
+ var doc = Roo.isIE ?
+ frame.contentWindow.document :
+ (frame.contentDocument || window.frames[Pman.Download.csvFrame.id].document);
+
+
+ if(doc && doc.body && doc.body.innerHTML.length){
+ // alert(doc.body.innerHTML);
+
+ Roo.MessageBox.alert("Download Error", doc.body.innerHTML);
+ success = false;
+ if (this.failure) {
+ this.failure();
+ }
+ return true;
+ }
+
+ Roo.log(doc.body.innerHTML);
+
+ }
+ catch(e) {
+ Roo.log(e.toString());
+ Roo.log(e);
+ }
+ if (this.success) {
+ this.success();
+ }
+ // we can not actually do anything with the frame... as it may actually still be downloading..
+ return true;
+
+ this.cleanup();
+
+ // this will never fire.. see
+ // http://www.atalasoft.com/cs/blogs/jake/archive/2009/08/18/events-to-expect-when-dynamically-loading-iframes-in-javascript-take-2-thanks-firefox-3-5.aspx
+ if (this.success && success) {
+
+ this.success();
+ }
+ return false;
+
+
+ },
+ */
+ // private - clean up download elements.
+ cleanup :function()
+ {
+ /* Roo.log('cleanup?');
+ if (this.form) {
+ this.form.remove();
+ this.form= false;
+
+ }
+
+ if (this.csvFrame) {
+ Roo.EventManager.removeListener(this.csvFrame, 'load', this.onLoad, this);
+ Roo.get(this.csvFrame).remove();
+ this.csvFrame= false;
+ }
+ */
+
+ },
+
+ buildFromGrid : function()
+ {
+ // get the params from beforeLoad
+ var ds = this.grid.ds;
+ ds.fireEvent('beforeload', ds, {
+ params : this.params
+
+ });
+
+ if(ds.sortInfo && ds.remoteSort){
+ var pn = ds.paramNames;
+ this.params[pn["sort"]] = ds.sortInfo.field;
+ this.params[pn["dir"]] = ds.sortInfo.direction;
+ }
+ if (ds.multiSort) {
+ var pn = ds.paramNames;
+ this.params[pn["multisort"]] = Roo.encode( { sort : ds.sortToggle, order: ds.sortOrder });
+ }
+
+
+
+ this.url = this.grid.ds.proxy.conn.url;
+ this.method = this.method || this.grid.ds.proxy.conn.method ;
+ var t = this;
+ // work out the cols
+
+ if (this.csvCols) {
+ t.params.csvCols = this.csvCols;
+ t.params.csvTitles = this.csvTitles;
+ } else {
+
+ Roo.each(this.grid.cm.config, function(c,i) {
+ t.params['csvCols['+i+']'] = c.dataIndex;
+ t.params['csvTitles['+i+']'] = c.header;
+
+ });
+ }
+ if (this.grid.loadMask) {
+ this.grid.loadMask.onLoad();
+ }
+ this.params.limit = this.limit;
+
+ // do it as a post, as args can get long..
+
+ this.method = 'POST';
+ if (this.method == 'POST') {
+ this.params._get = 1;
+ }