[pve-devel] [PATCH manager 1/5] fix #759: save columns of resourceGrid

Dominik Csapak d.csapak at proxmox.com
Fri Apr 15 15:26:25 CEST 2016


with this patch, the resourceGrid saves its state when
the columns are changed (resized, sorted, etc.)

also add a little reset button to the toolbar

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
the saveCurrentState is necessary, even if extjs saves the state
on its own, because it does this not everytime something changes
 www/css/ext6-pve.css              | 13 +++++++++++++
 www/manager6/grid/ResourceGrid.js | 33 +++++++++++++++++++++++++++++----
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/www/css/ext6-pve.css b/www/css/ext6-pve.css
index 4895623..cc75f75 100644
--- a/www/css/ext6-pve.css
+++ b/www/css/ext6-pve.css
@@ -345,3 +345,16 @@
 .x-form-display-field-default {
     min-height: 20px;
 }
+
+.x-button-reset:before {
+    font-size: 16px;
+}
+
+/* for resetcolumnsbutton */
+.x-button-reset:after{
+    content: "\f0e7 ";
+    position: relative;
+    text-shadow: 0 0 2px #fff;
+    left: -3px;
+    top: 2px;
+}
diff --git a/www/manager6/grid/ResourceGrid.js b/www/manager6/grid/ResourceGrid.js
index b97711f..bf4d727 100644
--- a/www/manager6/grid/ResourceGrid.js
+++ b/www/manager6/grid/ResourceGrid.js
@@ -3,7 +3,10 @@ Ext.define('PVE.grid.ResourceGrid', {
     alias: ['widget.pveResourceGrid'],
 
     border: false,
-
+    saveCurrentState: function(){
+	var me = this;
+	me.saveState();
+    },
     initComponent : function() {
 	var me = this;
 
@@ -149,7 +152,26 @@ Ext.define('PVE.grid.ResourceGrid', {
 
 	Ext.apply(me, {
 	    store: store,
+	    stateful: true,
+	    stateId: 'resourcegrid',
 	    tbar: [
+		{
+		    xtype: 'button',
+		    itemId: 'resetbutton',
+		    tooltip: gettext("Reset Columns"),
+		    iconCls: 'fa fa-fw fa-columns x-button-reset',
+		    handler: function(button, e, opts) {
+			var sp = Ext.state.Manager.getProvider();
+			me.getStore().sort([
+			    {
+				property : 'type',
+				direction: 'ASC'
+			    }
+			]);
+			me.reconfigure(null, me.ic);
+			sp.clear(me.stateId);
+		    }
+		},
 		'->', 
 		gettext('Search') + ':', ' ',
 		{
@@ -206,13 +228,16 @@ Ext.define('PVE.grid.ResourceGrid', {
 		},
 		destroy: function() {
 		    rstore.un("load", load_cb);
-		}
+		},
+		columnschanged: 'saveCurrentState',
+		columnresize: 'saveCurrentState',
+		columnmove: 'saveCurrentState',
+		sortchange: 'saveCurrentState',
 	    },
             columns: coldef
 	});
-
 	me.callParent();
-
+	me.ic = coldef;
 	updateGrid();
 	rstore.on("load", load_cb);
     }
-- 
2.1.4





More information about the pve-devel mailing list