← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6962: Added option for hiding columns by index or name to table plugin

 

------------------------------------------------------------
revno: 6962
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-16 14:56:16 +0200
message:
  Added option for hiding columns by index or name to table plugin
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/plugin.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/plugin.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/plugin.js	2012-05-15 22:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/plugin.js	2012-05-16 12:56:16 +0000
@@ -1092,6 +1092,7 @@
 		orgunits: [],
 		crosstab: ['data'],
 		orgUnitIsParent: false,
+		hiddenCols: [],
 		useExtGrid: false,
 		el: '',
 		url: ''
@@ -1146,10 +1147,12 @@
 		});
 		return headers;
 	},
-	getColumnArray: function(data) {
+	getColumnArray: function(conf,data) {
 		var columns = [];
 		Ext.Array.each(data.headers, function(header, index) {
-			columns.push({text: header.name, dataIndex: header.name});
+			if (!Ext.Array.contains(conf.hiddenCols, index) && !Ext.Array.contains(conf.hiddenCols, header)) {
+				columns.push({text: header.name, dataIndex: header.name});
+			}
 		});
 		return columns;
 	},
@@ -1168,7 +1171,7 @@
 			success: function(data) {
 				DHIS.table.tables[conf.el] = Ext.create('Ext.grid.Panel', {
 					store: DHIS.table.grid.getStore(data),
-					columns: DHIS.table.grid.getColumnArray(data),
+					columns: DHIS.table.grid.getColumnArray(conf,data),
 					renderTo: conf.el
 				});
 			}

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html	2012-05-15 22:32:35 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html	2012-05-16 12:56:16 +0000
@@ -5,7 +5,7 @@
     
     <script type="text/javascript" src="../../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
     <script type="text/javascript" src="../../../dhis-web-commons/javascripts/plugin/plugin.js"></script>
-    
+	
     <style type="text/css">
 		body {font-family: sans-serif; margin: 0 0 0 60px;}
 		
@@ -69,6 +69,7 @@
 				orgunits: ['ImspTQPwCqd'],
 				crosstab: ['periods'],
 				orgUnitIsParent: true,
+				hiddenCols: [0],
 				useExtGrid: true,
 				el: 'table2',
 				url: url

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js	2012-05-15 22:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js	2012-05-16 12:56:16 +0000
@@ -1092,6 +1092,7 @@
 		orgunits: [],
 		crosstab: ['data'],
 		orgUnitIsParent: false,
+		hiddenCols: [],
 		useExtGrid: false,
 		el: '',
 		url: ''
@@ -1146,10 +1147,12 @@
 		});
 		return headers;
 	},
-	getColumnArray: function(data) {
+	getColumnArray: function(conf,data) {
 		var columns = [];
 		Ext.Array.each(data.headers, function(header, index) {
-			columns.push({text: header.name, dataIndex: header.name});
+			if (!Ext.Array.contains(conf.hiddenCols, index) && !Ext.Array.contains(conf.hiddenCols, header)) {
+				columns.push({text: header.name, dataIndex: header.name});
+			}
 		});
 		return columns;
 	},
@@ -1168,7 +1171,7 @@
 			success: function(data) {
 				DHIS.table.tables[conf.el] = Ext.create('Ext.grid.Panel', {
 					store: DHIS.table.grid.getStore(data),
-					columns: DHIS.table.grid.getColumnArray(data),
+					columns: DHIS.table.grid.getColumnArray(conf,data),
 					renderTo: conf.el
 				});
 			}