DataObjects/Core_notify.php
[Pman.Core] / Pman.Download.js
index 8a0e66e..6c42308 100644 (file)
@@ -20,6 +20,8 @@ var t = new Pman.Download({
 * @cfg {String} url     Location to download from.
 * @cfg {String} method     GET or POST (default GET), POST will create a form, and post that into the hidden frame.
 * @cfg {Boolean} newWindow (optional) download to new window
+* @cfg {Boolean limit (optional) limit for grid downloads.
 * @cfg {Function} success (optional) MAY fire on download completed (fails on attachments)..
 * @cfg {Number} timeout (optional) in milliseconds before it gives up (default 30000 = 30s)
 * @cfg {Roo.grid.Grid} grid (optional) if you want to just download a grid, (without renderers..)
@@ -49,7 +51,7 @@ Pman.Download = function(cfg)
    
     
     
-    var submit = false;
+    this.submit = false;
     this.createCsvFrame();
     
     var requested = 0;
@@ -62,9 +64,9 @@ Pman.Download = function(cfg)
     
     if (this.method == 'GET' && !this.params) {
         (function() {
-            submit = true;
+            this.submit = true;
             this.csvFrame.src = cfg.url;
-            this.cleanup.defer(cfg.timeout || 30000,this);
+            //this.cleanup.defer(cfg.timeout || 30000,this);
         }).defer(100, this);
         
        
@@ -101,7 +103,7 @@ Pman.Download = function(cfg)
     }
     
     (function() {
-        submit = true;
+        this.submit = true;
         this.form.dom.submit();
         this.cleanup.defer(this.timeout || 30000,this);
     }).defer(100, this);
@@ -121,10 +123,11 @@ Roo.apply(Pman.Download.prototype, {
     // private
     form : false,
     
+    limit : 9999,
+    
     // private..
     createCsvFrame: function()
     {
-        
         if (this.csvFrame) {
             document.body.removeChild(this.csvFrame);
         }
@@ -151,10 +154,11 @@ Roo.apply(Pman.Download.prototype, {
        // if (requested < 2) {
        //     return;
         //} // n
+        Roo.log('onload?');
         if (!this.submit) {
-            return;
+            return false;
         }
-        
+        return false;
       
         var frame = this.csvFrame;
         var success  = true; 
@@ -180,7 +184,9 @@ Roo.apply(Pman.Download.prototype, {
             Roo.log(e.toString());
             Roo.log(e);
         }
-        
+        // 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 
@@ -189,7 +195,7 @@ Roo.apply(Pman.Download.prototype, {
             
             this.success();
         }
-       
+        return false;
         
 
     },
@@ -197,6 +203,7 @@ Roo.apply(Pman.Download.prototype, {
     // private - clean up download elements.
     cleanup :function()
     {
+        Roo.log('cleanup?');
         if (this.form) {
             this.form.remove();
             this.form= false;
@@ -214,10 +221,24 @@ Roo.apply(Pman.Download.prototype, {
     buildFromGrid : function()
     {
         // get the params from beforeLoad
-        this.grid.ds.fireEvent('beforeload', this.grid.ds, {
+        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.grid.ds.proxy.conn.method ;
         var t = this;
@@ -227,11 +248,11 @@ Roo.apply(Pman.Download.prototype, {
             t.params['csvTitles['+i+']'] = c.header;
             
         });
-        this.grid.ds.fireEvent('load', this.grid.ds, {
-            params : this.params
-            
-        });
-        this.params.limit = 9999;
+        
+        if (this.grid.loadMask) {
+            this.grid.loadMask.onLoad();
+        }
+        this.params.limit = this.limit;
         
         
     }