Fix selecting all rows in a viewport
authorMichael M Slusarz <slusarz@curecanti.org>
Sun, 21 Nov 2010 19:09:02 +0000 (12:09 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Sun, 21 Nov 2010 19:09:02 +0000 (12:09 -0700)
imp/js/dimpbase.js
imp/js/viewport.js

index 6d83329..99ee0c8 100644 (file)
@@ -56,7 +56,7 @@ var DimpBase = {
             if (selcount) {
                 if (!sel || selcount != 1) {
                     bounds = [ rownum, this.pivotrow ];
-                    this.viewport.select($A($R(bounds.min(), bounds.max())), { range: true });
+                    this.viewport.select($A($R(bounds.min(), bounds.max())));
                 }
                 return;
             }
@@ -76,7 +76,7 @@ var DimpBase = {
 
     selectAll: function()
     {
-        this.viewport.select(this.viewport.getAllRows(), { range: true });
+        this.viewport.select($A($R(1, this.viewport.getMetaData('total_rows'))));
     },
 
     isSelected: function(format, data)
index d33bfde..6622fc6 100644 (file)
@@ -1281,7 +1281,7 @@ var ViewPort = Class.create({
 
     // vs = (ViewPort_Selection | array) A ViewPort_Selection object -or- if
     //       opts.range is set, an array of row numbers.
-    // opts = (object) TODO [add, range, search]
+    // opts = (object) [add, search]
     select: function(vs, opts)
     {
         opts = opts || {};
@@ -1289,26 +1289,26 @@ var ViewPort = Class.create({
         var b = this._getBuffer(),
             sel, slice;
 
+        if (Object.isArray(vs)) {
+            slice = this.createSelection('rownum', vs);
+            if (vs.size() != slice.size()) {
+                this.opts.container.fire('ViewPort:fetch', this.view);
+                return this._ajaxRequest({ rangeslice: 1, slice: vs.min() + ':' + vs.size() });
+            }
+            vs = slice;
+        }
+
         if (opts.search) {
             return this._fetchBuffer({
                 callback: function(r) {
                     if (r.rownum) {
-                        this.select(this.createSelection('rownum', [ r.rownum ]), { add: opts.add, range: opts.range });
+                        this.select(this.createSelection('rownum', [ r.rownum ]), { add: opts.add });
                     }
                 }.bind(this),
                 search: opts.search
             });
         }
 
-        if (opts.range) {
-            slice = this.createSelection('rownum', vs);
-            if (vs.size() != slice.size()) {
-                this.opts.container.fire('ViewPort:fetch', this.view);
-                return this._ajaxRequest({ rangeslice: 1, slice: vs.min() + ':' + vs.size() });
-            }
-            vs = slice;
-        }
-
         if (!opts.add) {
             sel = this.getSelected();
             b.deselect(sel, true);