[pve-devel] r5810 - pve-manager/pve2/www/new/grid

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Apr 12 13:36:00 CEST 2011


Author: dietmar
Date: 2011-04-12 13:36:00 +0200 (Tue, 12 Apr 2011)
New Revision: 5810

Modified:
   pve-manager/pve2/www/new/grid/ResourceGrid.js
Log:
use chunking feature


Modified: pve-manager/pve2/www/new/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-12 09:12:53 UTC (rev 5809)
+++ pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-12 11:36:00 UTC (rev 5810)
@@ -1,3 +1,18 @@
+// fixme: remove this fix
+// this hack is required for ExtJS beta2
+Ext.override(Ext.grid.feature.Chunking, {
+    attachEvents: function() {
+	console.log("TESTCF");
+        var grid = this.view.up('gridpanel'),
+            scroller = grid.down('gridscroller[dock=right]');
+        if (scroller === null ) {
+            grid.on("afterlayout", this.attachEvents, this, { single : true });
+            return false;
+        }
+        scroller.el.on('scroll', this.onBodyScroll, this, {buffer: 300});
+    }
+});
+
 Ext.define('PVE.grid.ResourceGrid', {
     extend: 'Ext.grid.GridPanel',
     requires: [
@@ -2,11 +17,11 @@
 	'Ext.grid.*',
+	'Ext.grid.feature.Chunking',
 	'Ext.data.*',
-	'Ext.data.BufferStore',
+	'Ext.data.Store',
 	'Ext.util.*',
-	'Ext.grid.PagingScroller',
 	'PVE.Utils', 
 	'PVE.data.ResourceStore'
     ],
     alias: ['widget.pveResourceGrid'],
-
+    features: [ {ftype: 'chunking'}],
     
@@ -19,10 +34,8 @@
 
 	var coldef = rstore.defaultColums();
 
-	var store = Ext.create('Ext.data.BufferStore', {
-            pageSize: 50,
-            purgePageCount: 0,
-	    model: 'PVEResources',
+	var store = Ext.create('Ext.data.Store', {
+ 	    model: 'PVEResources',
 	    proxy: { type: 'memory' }
 	});
 
@@ -63,11 +76,11 @@
 
                 for (; i < len; i++) {
                     n = cs[i];
-		    //if (textfilter && !textfilter_match(n))
-		    //continue;
+		    if (textfilter && !textfilter_match(n))
+			continue;
 
 		    var orgnode = rstore.data.get(n.data.id);
-		    if (orgnode) 
+		    if (orgnode)
 			nodeidx[n.data.id] = rstore.data.get(n.data.id);
  		    gather_child_nodes(n);
 		}
@@ -86,7 +99,7 @@
 
 	    if (rmlist.length)
 		store.remove(rmlist);
-
+	    
  	    // add new items
 	    var addlist = [];
 	    for (var key in nodeidx) {
@@ -122,13 +135,11 @@
 		}
 	    };
 
-	    if (addlist.length) {
-		store.cacheRecords(addlist);
-		store.guaranteeRange(0, 50);
-	    }
-
 	    store.sort();
 
+	    if (addlist.length)
+		store.add(addlist);
+
 	    store.resumeEvents();
 
 	    store.fireEvent('datachanged', store);
@@ -144,9 +155,11 @@
 
 	var filter_task = new Ext.util.DelayedTask(function(){
 	    console.log("run filter " + textfilter);
+	    //store.filterBy(textfilter_match, store);
 	    updateGrid(true);
 	});
 
+
 	var load_cb = function() { updateGrid(false); };
 
 	Ext.apply(me, {
@@ -173,15 +186,10 @@
 		}
 	    ],
  	    viewConfig: {
-		invalidateScrollerOnRefresh: false,
 		stripeRows: true,
 		trackOver: false
             },
- 	    verticalScroller: {
-		xtype: 'paginggridscroller',
-		activePrefetch: false
-            },
- 	    listeners: {
+	    listeners: {
 		destroy: function() {
 		    rstore.un("load", load_cb)
 		}




More information about the pve-devel mailing list