[fusion-commits] r2228 - sandbox/jxlib-3.0/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Mon Sep 13 08:47:18 EDT 2010


Author: pagameba
Date: 2010-09-13 12:47:18 +0000 (Mon, 13 Sep 2010)
New Revision: 2228

Modified:
   sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
Log:
new sorting method should speed up sorting on large sets in the data grid.

Modified: sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
===================================================================
--- sandbox/jxlib-3.0/lib/jxlib.uncompressed.js	2010-09-13 11:57:00 UTC (rev 2227)
+++ sandbox/jxlib-3.0/lib/jxlib.uncompressed.js	2010-09-13 12:47:18 UTC (rev 2228)
@@ -18242,7 +18242,7 @@
 
 ...
  */
-// $Id: store.js 972 2010-08-25 17:56:46Z pagameba $
+// $Id: store.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Store
  *
@@ -31138,7 +31138,7 @@
 
 ...
  */
-// $Id: column.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: column.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Column
  *
@@ -31525,7 +31525,7 @@
 
 ...
  */
-// $Id: columns.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: columns.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Columns
  *
@@ -31989,7 +31989,7 @@
 
 ...
  */
-// $Id: row.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: row.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Row
  *
@@ -32337,7 +32337,7 @@
 
 ...
  */
-// $Id: grid.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Grid
  *
@@ -32620,7 +32620,7 @@
     
     if (store instanceof Jx.Store) {
       store.addEvent('storeDataLoaded', this.storeLoaded);
-      store.addEvent('storeSortFinished', this.drawStore);
+      // store.addEvent('storeSortFinished', this.drawStore);
       store.addEvent('storeRecordAdded', this.addRow);
       store.addEvent('storeColumnChanged', this.updateRow);
       store.addEvent('storeRecordRemoved', this.removeRow);
@@ -32678,7 +32678,6 @@
         height : colHeaderHeight
     });
     
-    
     this.columnContainer.setStyles({
       top: 0,
       left: rowHeaderWidth
@@ -33508,7 +33507,7 @@
 
 ...
  */
-// $Id: grid.selector.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.selector.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Selector
  *
@@ -34080,7 +34079,7 @@
 
 ...
  */
-// $Id: grid.prelighter.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.prelighter.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Prelighter
  *
@@ -34391,7 +34390,7 @@
  - emblems.png
 ...
  */
-// $Id: grid.sorter.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.sorter.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Sorter
  *
@@ -34404,111 +34403,142 @@
  *
  * This file is licensed under an MIT style license
  */
- Jx.Plugin.Grid.Sorter = new Class({
-   Family: 'Jx.Plugin.Grid.Sorter',
-   Extends: Jx.Plugin,
-   name: 'Prelighter',
-   
-   Binds: ['sort', 'modifyHeaders'],
+Jx.Plugin.Grid.Sorter = new Class({
+  Family: 'Jx.Plugin.Grid.Sorter',
+  Extends: Jx.Plugin,
+  name: 'Prelighter',
 
-   /**
-    * Property: current
-    * refernce to the currently sorted column
-    */
-   current: null,
+  Binds: ['sort', 'modifyHeaders'],
 
-   /**
-    * Property: direction
-    * tell us what direction the sort is in (either 'asc' or 'desc')
-    */
-   direction: null,
+  /**
+   * Property: current
+   * refernce to the currently sorted column
+   */
+  current: null,
 
-   options: {
-     sortableClass: 'jxColSortable',
-     ascendingClass: 'jxGridColumnSortedAsc',
-     descendingClass: 'jxGridColumnSortedDesc'
-   },
+  /**
+   * Property: direction
+   * tell us what direction the sort is in (either 'asc' or 'desc')
+   */
+  direction: null,
 
-   /**
-    * APIMethod: attach
-    * Sets up the plugin and attaches the plugin to the grid events it
-    * will be monitoring
-    */
-   attach: function(grid) {
-     if (!$defined(grid) && !(grid instanceof Jx.Grid)) {
-         return;
-     }
-     this.parent(grid);
+  options: {
+    sortableClass: 'jxColSortable',
+    ascendingClass: 'jxGridColumnSortedAsc',
+    descendingClass: 'jxGridColumnSortedDesc'
+  },
 
-     this.grid = grid;
+  /**
+   * APIMethod: attach
+   * Sets up the plugin and attaches the plugin to the grid events it
+   * will be monitoring
+   */
+  attach: function(grid) {
+    if (!$defined(grid) && !(grid instanceof Jx.Grid)) {
+        return;
+    }
+    this.parent(grid);
 
-     // this.grid.wantEvent('gridColumnClick');
-     this.grid.addEvent('gridColumnClick', this.sort);
-     this.grid.addEvent('doneCreateGrid', this.modifyHeaders);
-   },
+    this.grid = grid;
 
-   /**
-    * APIMethod: detach
-    */
-   detach: function() {
-     if (this.grid) {
-         this.grid.removeEvent('gridColumnClick', this.sort);
-     }
-     this.grid = null;
-   },
+    // this.grid.wantEvent('gridColumnClick');
+    this.grid.addEvent('gridColumnClick', this.sort);
+    this.grid.addEvent('doneCreateGrid', this.modifyHeaders);
+  },
 
-   /**
-    * Method: modifyHeaders
-    */
-   modifyHeaders: function() {
-     var grid = this.grid,
-         columnTable = grid.colObj,
-         store = grid.store,
-         c = this.options.sortableClass;
-     if (grid.columns.useHeaders()) {
-       grid.columns.columns.each(function(col, index) {
-         if (!col.isHidden() && col.isSortable()) {
-           var th = columnTable.getElement('.jxGridCol'+index);
-           th.addClass(c);
-         }
-       });
-     }
-   },
+  /**
+   * APIMethod: detach
+   */
+  detach: function() {
+    if (this.grid) {
+        this.grid.removeEvent('gridColumnClick', this.sort);
+    }
+    this.grid = null;
+  },
 
-   /**
-    * Method: sort
-    * called when a grid header is clicked.
-    *
-    * Parameters:
-    * cell - The cell clicked
-    */
-   sort: function(el) {
-     var current = this.current,
-         store = this.grid.store,
-         sorter = store.getStrategy('sort'),
-         data = el.retrieve('jxCellData'),
-         dir = 'asc',
-         opt = this.options;
+  /**
+   * Method: modifyHeaders
+   */
+  modifyHeaders: function() {
+    var grid = this.grid,
+        columnTable = grid.colObj,
+        store = grid.store,
+        c = this.options.sortableClass;
+    if (grid.columns.useHeaders()) {
+      grid.columns.columns.each(function(col, index) {
+        if (!col.isHidden() && col.isSortable()) {
+          var th = columnTable.getElement('.jxGridCol'+index);
+          th.addClass(c);
+        }
+      });
+    }
+  },
 
-     if (sorter && $defined(data.column) && data.column.isSortable()) {
-       if (el.hasClass(opt.ascendingClass)) {
-         el.removeClass(opt.ascendingClass).addClass(opt.descendingClass);
-         dir = 'desc';
-       } else if (el.hasClass(opt.descendingClass)) {
-         el.removeClass(opt.descendingClass).addClass(opt.ascendingClass);
-       } else {
-         el.addClass(opt.ascendingClass);
-       }
-       if (current && el != current) {
-         current.removeClass(opt.ascendingClass).removeClass(opt.descendingClass);
-       }
-       this.current = el;
-       sorter.sort(data.column.name, null, dir);
-     }
-   }
- });
+  /**
+   * Method: sort
+   * called when a grid header is clicked.
+   *
+   * Parameters:
+   * cell - The cell clicked
+   */
+  sort: function(el) {
+    var current = this.current,
+        grid = this.grid,
+        gridTableBody = grid.gridTableBody,
+        gridParent = gridTableBody.getParent(),
+        rowTableBody = grid.rowTableBody,
+        rowParent = rowTableBody.getParent(),
+        useHeaders = grid.row.useHeaders(),
+        store = grid.store,
+        sorter = store.getStrategy('sort'),
+        data = el.retrieve('jxCellData'),
+        dir = 'asc',
+        opt = this.options;
 
-/*
+    if (sorter && $defined(data.column) && data.column.isSortable()) {
+      if (el.hasClass(opt.ascendingClass)) {
+        el.removeClass(opt.ascendingClass).addClass(opt.descendingClass);
+        dir = 'desc';
+      } else if (el.hasClass(opt.descendingClass)) {
+        el.removeClass(opt.descendingClass).addClass(opt.ascendingClass);
+      } else {
+        el.addClass(opt.ascendingClass);
+      }
+      if (current && el != current) {
+        current.removeClass(opt.ascendingClass).removeClass(opt.descendingClass);
+      }
+      this.current = el;
+      gridTableBody.dispose();
+      if (useHeaders) {
+        rowTableBody.dispose();
+      }
+      store.each(function(record, index) {
+        record.dom = {
+          cell: gridTableBody.childNodes[index],
+          row: useHeaders ? rowTableBody.childNodes[index] : null
+        };
+      });
+      
+      // store.removeEvent('storeSortFinished', grid.drawStore);
+      sorter.sort(data.column.name, null, dir);
+      // store.addEvent('storeSortFinished', grid.drawStore);
+      
+      store.each(function(record, index) {
+        record.dom.cell.inject(gridTableBody);
+        if (useHeaders) {
+          record.dom.row.inject(rowTableBody);
+        }
+      });
+      
+      if (gridParent) {
+        gridParent.adopt(gridTableBody);
+      }
+      if (useHeaders && rowParent) {
+        rowParent.adopt(rowTableBody);
+      }
+    }
+  }
+});/*
 ---
 
 name: Jx.Plugin.Grid.Resize
@@ -34524,7 +34554,7 @@
 
 ...
  */
-// $Id: grid.resize.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.resize.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Resize
  *
@@ -34725,7 +34755,7 @@
  - icons.png
 ...
  */
-// $Id: grid.editor.js 960 2010-06-06 22:23:16Z jonlb at comcast.net $
+// $Id: grid.editor.js 981 2010-09-13 12:18:35Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Editor
  *



More information about the fusion-commits mailing list