[pve-devel] r5805 - in pve-manager/pve2/www/new: grid tree

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Apr 8 12:56:41 CEST 2011


Author: dietmar
Date: 2011-04-08 12:56:41 +0200 (Fri, 08 Apr 2011)
New Revision: 5805

Modified:
   pve-manager/pve2/www/new/grid/ResourceGrid.js
   pve-manager/pve2/www/new/tree/ResourceTree.js
Log:
test using buffered grid


Modified: pve-manager/pve2/www/new/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-08 07:53:40 UTC (rev 5804)
+++ pve-manager/pve2/www/new/grid/ResourceGrid.js	2011-04-08 10:56:41 UTC (rev 5805)
@@ -1,18 +1,111 @@
 Ext.define('PVE.grid.ResourceGrid', {
     extend: 'Ext.grid.GridPanel',
-    requires: ['PVE.Utils', 
-	       'PVE.data.ResourceStore'],
+    requires: [
+	'Ext.grid.*',
+	'Ext.data.*',
+	'Ext.data.BufferStore',
+	'Ext.util.*',
+	'Ext.grid.PagingScroller',
+	'PVE.Utils', 
+	'PVE.data.ResourceStore'
+    ],
     alias: ['widget.pveResourceGrid'],
 
     
     initComponent : function() {
 	var me = this;
 
-	var store = PVE.data.ResourceStore;
+	var rstore = PVE.data.ResourceStore;
 
+	var store = Ext.create('Ext.data.BufferStore', {
+            pageSize: 50,
+            purgePageCount: 0,
+	    model: 'PVEResources',
+	    proxy: { type: 'memory' }
+	});
+
+	var pdata = {
+	    dataIndex: {},
+	    updateCount: 0
+	};
+
+	var updateGrid = function() {
+
+	    var index = pdata.dataIndex;
+
+	    var filterfn = null;
+	    
+	    console.log("START GRID UPDATE");
+
+	    // remove vanished or changed items
+	    var rmlist = [];
+	    for (var key in index) {
+		if (!index.hasOwnProperty(key))
+		    continue;
+
+		var olditem = index[key];
+
+		// getById() use find(), which is slow (ExtJS4 beta2) 
+		//var item = rstore.getById(olditem.data.id);
+		var item = rstore.data.get(olditem.data.id);
+
+		if (!item) {
+		    console.log("GRID REM UID: " + key + " ITEM " + olditem.data.id);
+		    delete index[key];
+		    rmlist.push(item);
+
+		}
+	    }
+	    if (rmlist.length) 
+		store.remove(rmlist);
+
+ 	    // add new items
+	    var addlist = [];
+            rstore.each(function(item) {
+		var olditem = index[item.data.id];
+		if (olditem)
+		    return;
+
+		if (filterfn && !filterfn(item))
+		    return;
+
+		//console.log("GRID ADD UID: " + item.data.id);
+
+		var info = Ext.apply({}, item.data);
+		var child = Ext.ModelMgr.create(info, store.model, info.id);
+		addlist.push(item);
+		index[item.data.id] = child;
+	    });
+
+	    if (addlist.length) {
+		store.cacheRecords(addlist);
+		store.guaranteeRange(0, 49);
+	    }
+
+	    console.log("END GRID UPDATE");
+	    if (!pdata.updateCount) {
+		//self.applyState(sp.get(stateid));
+	    }
+
+	    pdata.updateCount++;
+	};
+
 	Ext.apply(me, {
 	    title: 'Search',
 	    store: store,
+	    viewConfig: {
+		trackOver: false
+            },
+            invalidateScrollerOnRefresh: false,
+	    verticalScroller: {
+		xtype: 'paginggridscroller',
+		activePrefetch: false
+            },
+ 	    listeners: {
+		destroy: function() {
+		    rstore.un("load", updateGrid)
+		}
+	    },
             columns:[{
 		text: 'ID',
 		dataIndex: 'id'
@@ -20,5 +113,8 @@
 	});
 
 	me.callParent();
+
+	updateGrid();
+	rstore.on("load", updateGrid);
     }
 });
\ No newline at end of file

Modified: pve-manager/pve2/www/new/tree/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-08 07:53:40 UTC (rev 5804)
+++ pve-manager/pve2/www/new/tree/ResourceTree.js	2011-04-08 10:56:41 UTC (rev 5805)
@@ -186,6 +186,8 @@
 
 	var updateTree = function() {
 
+	    // fixme: suspend events ?
+
 	    var rootnode = self.store.getRootNode();
 
 	    var index = pdata.dataIndex;




More information about the pve-devel mailing list