← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10936: (PT) Categories supported.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 10936 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-05-22 16:37:21 +0200
message:
  (PT) Categories supported.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/java/org/hisp/dhis/pivot/action/InitializeAction.java
  dhis-2/dhis-web/dhis-web-pivot/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.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-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-04-17 14:53:47 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-05-16 09:32:16 +0000
@@ -1339,6 +1339,8 @@
 						iid = feature.attributes.internalId;
 					if (featureMap.hasOwnProperty(iid) && valueMap.hasOwnProperty(iid)) {
 						feature.attributes.value = valueMap[iid];
+						//var m = Math.random();
+						//feature.attributes.value = m < 0.3 ? -5 : m < 0.6 ? null : 1;
 						feature.attributes.label = feature.attributes.name + ' (' + feature.attributes.value + ')';
 						newFeatures.push(feature);
 					}

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/java/org/hisp/dhis/pivot/action/InitializeAction.java'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/java/org/hisp/dhis/pivot/action/InitializeAction.java	2013-04-15 20:44:56 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/java/org/hisp/dhis/pivot/action/InitializeAction.java	2013-05-15 09:45:38 +0000
@@ -33,14 +33,11 @@
 
 import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.api.utils.ContextUtils;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
-import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.common.DimensionalObject;
+import org.hisp.dhis.common.DimensionService;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.mapping.MapLegendSet;
-import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -66,20 +63,6 @@
         this.organisationUnitService = organisationUnitService;
     }
 
-    private OrganisationUnitGroupService organisationUnitGroupService;
-
-    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
-    {
-        this.organisationUnitGroupService = organisationUnitGroupService;
-    }
-    
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
     private PeriodService periodService;
 
     public void setPeriodService( PeriodService periodService )
@@ -87,11 +70,11 @@
         this.periodService = periodService;
     }
     
-    private MappingService mappingService;
+    private DimensionService dimensionService;
 
-    public void setMappingService( MappingService mappingService )
+    public void setDimensionService( DimensionService dimensionService )
     {
-        this.mappingService = mappingService;
+        this.dimensionService = dimensionService;
     }
 
     private I18nFormat format;
@@ -119,20 +102,6 @@
         return rootNodes;
     }
 
-    private Collection<OrganisationUnitGroupSet> organisationUnitGroupSets;
-
-    public Collection<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
-    {
-        return organisationUnitGroupSets;
-    }
-
-    private Collection<DataElementGroupSet> dataElementGroupSets;
-
-    public Collection<DataElementGroupSet> getDataElementGroupSets()
-    {
-        return dataElementGroupSets;
-    }
-
     private List<Period> lastMonth;
 
     public List<Period> getLastMonth()
@@ -202,6 +171,13 @@
     {
         return last5Years;
     }
+    
+    private Collection<DimensionalObject> dimensions;
+
+    public Collection<DimensionalObject> getDimensions()
+    {
+        return dimensions;
+    }
 
     private Collection<MapLegendSet> legendSets;
 
@@ -226,10 +202,6 @@
             rootNodes.add( new OrganisationUnit() );
         }
 
-        organisationUnitGroupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
-        
-        dataElementGroupSets = dataElementService.getAllDataElementGroupSets();
-
         RelativePeriods rp = new RelativePeriods();
 
         rp.clear().setReportingMonth( true );
@@ -262,7 +234,7 @@
         rp.clear().setLast5Years( true );
         last5Years = periodService.reloadPeriods( setNames( rp.getRelativePeriods() ) );
         
-        legendSets = mappingService.getAllMapLegendSets();
+        dimensions = dimensionService.getAllDimensions();
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/resources/META-INF/dhis/beans.xml	2013-04-15 20:44:56 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/resources/META-INF/dhis/beans.xml	2013-05-15 09:45:38 +0000
@@ -13,11 +13,9 @@
   <bean id="org.hisp.dhis.pivot.action.InitializeAction"
     class="org.hisp.dhis.pivot.action.InitializeAction"
     scope="prototype">
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+    <property name="dimensionService" ref="org.hisp.dhis.common.DimensionService" />
   </bean>
 
   <!-- OrganisationUnit -->

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-05-09 19:52:43 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-05-22 14:06:23 +0000
@@ -17,9 +17,9 @@
 
 	// Init
 
-	var pt = PT.core.getInstance();
+	pt = PT.core.getInstance();
 
-	PT.app.instances = [pt];
+	PT.core.instances = [pt];
 
 	PT.app.getInits = function(r) {
 		var init = Ext.decode(r.responseText);
@@ -28,22 +28,17 @@
 			init.rootNodes[i].path = '/' + pt.conf.finals.root.id + '/' + init.rootNodes[i].id;
 		}
 
-		// Ougs
-		for (var i = 0, dim = pt.conf.finals.dimension, oug; i < init.ougs.length; i++) {
-			oug = init.ougs[i];
-			oug.dimensionName = oug.id;
-			oug.objectName = pt.conf.finals.dimension.organisationUnitGroupSet.objectName;
-			dim.objectNameMap[oug.id] = oug;
-		}
-
-		// Degs
-		for (var i = 0, dim = pt.conf.finals.dimension, deg; i < init.degs.length; i++) {
-			deg = init.degs[i];
-			deg.dimensionName = deg.id;
-			deg.objectName = pt.conf.finals.dimension.dataElementGroupSet.objectName;
-			dim.objectNameMap[deg.id] = deg;
-		}
-
+		// Sort and extend dynamic dimensions
+		init.dimensions = pt.util.array.sortObjectsByString(init.dimensions);
+
+		for (var i = 0, dim; i < init.dimensions.length; i++) {
+			dim = init.dimensions[i];
+			dim.dimensionName = dim.id;
+			dim.objectName = pt.conf.finals.dimension.dimension.objectName;
+			pt.conf.finals.dimension.objectNameMap[dim.id] = dim;
+		}
+
+		// Viewport afterrender
 		init.afterRender = function() {
 
 			// Resize event handler
@@ -57,7 +52,7 @@
 
 			// Left gui
 			var viewportHeight = pt.viewport.westRegion.getHeight(),
-				numberOfTabs = pt.init.ougs.length + pt.init.degs.length + 5,
+				numberOfTabs = pt.init.dimensions.length + 5,
 				tabHeight = 28,
 				minPeriodHeight = 380;
 
@@ -95,6 +90,72 @@
 	PT.app.getUtils = function() {
 		var util = pt.util || {};
 
+		util.pivot.getLayoutConfig = function() {
+			var panels = pt.cmp.dimension.panels,
+				columnDimNames = pt.viewport.colStore.getDimensionNames(),
+				rowDimNames = pt.viewport.rowStore.getDimensionNames(),
+				filterDimNames = pt.viewport.filterStore.getDimensionNames(),
+				config = pt.viewport.optionsWindow.getOptions(),
+				dimConf = pt.conf.finals.dimension,
+				dx = dimConf.data.dimensionName,
+				co = dimConf.category.dimensionName,
+				nameDimArrayMap = {},
+				getDimension;
+
+			config.columns = [];
+			config.rows = [];
+			config.filters = [];
+
+			// Panel data
+			for (var i = 0, dim, dimName; i < panels.length; i++) {
+				dim = panels[i].getDimension();
+
+				if (dim) {
+					nameDimArrayMap[dim.dimension] = [dim];
+				}
+			}
+
+			nameDimArrayMap[dx] = Ext.Array.clean([].concat(
+				nameDimArrayMap[dimConf.indicator.objectName],
+				nameDimArrayMap[dimConf.dataElement.objectName],
+				nameDimArrayMap[dimConf.operand.objectName],
+				nameDimArrayMap[dimConf.dataSet.objectName]
+			));
+
+			// Columns, rows, filters
+			for (var i = 0, nameArrays = [columnDimNames, rowDimNames, filterDimNames], axes = [config.columns, config.rows, config.filters], dimNames; i < nameArrays.length; i++) {
+				dimNames = nameArrays[i];
+
+				for (var j = 0, dimName, dim; j < dimNames.length; j++) {
+					dimName = dimNames[j];
+
+					if (dimName === co) {
+						axes[i].push({
+							dimension: co,
+							items: []
+						});
+					}
+					else if (dimName === dx && nameDimArrayMap.hasOwnProperty(dimName) && nameDimArrayMap[dimName]) {
+						for (var k = 0; k < nameDimArrayMap[dx].length; k++) {
+							axes[i].push(Ext.clone(nameDimArrayMap[dx][k]));
+						}
+					}
+					else if (nameDimArrayMap.hasOwnProperty(dimName) && nameDimArrayMap[dimName]) {
+						//axes[i].push(Ext.clone(nameDimArrayMap[dimName]));
+
+						for (var k = 0; k < nameDimArrayMap[dimName].length; k++) {
+							axes[i].push(Ext.clone(nameDimArrayMap[dimName][k]));
+						}
+					}
+				}
+			}
+
+			config.userOrganisationUnit = pt.viewport.userOrganisationUnit.getValue();
+			config.userOrganisationUnitChildren = pt.viewport.userOrganisationUnitChildren.getValue();
+
+			return config;
+		};
+
 		util.dimension = {
 			panel: {
 				setHeight: function(mx) {
@@ -166,80 +227,6 @@
 			}
 		};
 
-		util.pivot.getLayoutConfig = function() {
-			var data = {},
-				setup = pt.viewport.layoutWindow ? pt.viewport.layoutWindow.getSetup() : {},
-				getData,
-				extendLayout,
-				config;
-
-			config = {
-				col: [],
-				row: [],
-				filter: [],
-				objects: [],
-				userOrganisationUnit: false,
-				userOrganisationUnitChildren: false
-			};
-
-			getData = function() {
-				var panels = pt.cmp.dimension.panels,
-					dxItems = [];
-
-				for (var i = 0, dim; i < panels.length; i++) {
-					dim = panels[i].getData();
-
-					if (dim) {
-						config.objects.push(dim);
-
-						if (dim.dimensionName === pt.conf.finals.dimension.data.dimensionName) {
-							dxItems = dxItems.concat(dim.items);
-						}
-						else {
-							data[dim.dimensionName] = dim.items;
-						}
-					}
-				}
-
-				if (dxItems.length) {
-					data[pt.conf.finals.dimension.data.dimensionName] = dxItems;
-				}
-			}();
-
-			extendLayout = function() {
-				for (var i = 0, dimensionName; i < setup.col.length; i++) {
-					dimensionName = setup.col[i];
-					config.col.push({
-						dimensionName: dimensionName,
-						items: data[dimensionName]
-					});
-				}
-
-				for (var i = 0, dimensionName; i < setup.row.length; i++) {
-					dimensionName = setup.row[i];
-					config.row.push({
-						dimensionName: dimensionName,
-						items: data[dimensionName]
-					});
-				}
-
-				for (var i = 0, dimensionName; i < setup.filter.length; i++) {
-					dimensionName = setup.filter[i];
-					config.filter.push({
-						dimensionName: dimensionName,
-						items: data[dimensionName]
-					});
-				}
-			}();
-
-			config.options = pt.viewport.optionsWindow.getOptions();
-
-			config.options.userOrganisationUnit = pt.viewport.userOrganisationUnit.getValue();
-			config.options.userOrganisationUnitChildren = pt.viewport.userOrganisationUnitChildren.getValue();
-
-			return config;
-		};
-
 		util.url = {
 			getUrlParam: function(s) {
 				var output = '';
@@ -489,10 +476,7 @@
 				data.push({id: dimConf.organisationUnit.dimensionName, name: dimConf.organisationUnit.name});
 			}
 
-			return data.concat(
-				pt.util.array.sortObjectsByString(Ext.clone(pt.init.ougs)),
-				pt.util.array.sortObjectsByString(Ext.clone(pt.init.degs))
-			);
+			return data.concat(Ext.clone(pt.init.dimensions));
 		};
 
 		getStore = function(data) {
@@ -504,6 +488,16 @@
 				config.data = data;
 			}
 
+			config.getDimensionNames = function() {
+				var dimensionNames = [];
+
+				this.each(function(r) {
+					dimensionNames.push(r.data.id);
+				});
+
+				return Ext.clone(dimensionNames);
+			};
+
 			return Ext.create('Ext.data.Store', config);
 		};
 
@@ -947,6 +941,19 @@
 					parentOrganisationUnit: parentOrganisationUnit.getValue()
 				};
 			},
+			setOptions: function(layout) {
+				showTotals.setValue(Ext.isBoolean(layout.showTotals) ? layout.showTotals : true);
+				showSubTotals.setValue(Ext.isBoolean(layout.showSubTotals) ? layout.showSubTotals : true);
+				hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false);
+
+				displayDensity.setValue(Ext.isString(layout.displayDensity) ? layout.displayDensity : 'normal');
+				fontSize.setValue(Ext.isString(layout.fontSize) ? layout.fontSize : 'normal');
+				digitGroupSeparator.setValue(Ext.isString(layout.digitGroupSeparator) ? layout.digitGroupSeparator : 'space');
+
+				reportingPeriod.setValue(Ext.isBoolean(layout.reportingPeriod) ? layout.reportingPeriod : false);
+				organisationUnit.setValue(Ext.isBoolean(layout.organisationUnit) ? layout.organisationUnit : false);
+				parentOrganisationUnit.setValue(Ext.isBoolean(layout.parentOrganisationUnit) ? layout.parentOrganisationUnit : false);
+			},
 			items: [
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
@@ -1053,8 +1060,8 @@
 		getBody = function() {
 			var favorite;
 
-			if (pt.xLayout) {
-				favorite = Ext.clone(pt.xLayout.options);
+			if (pt.layout) {
+				favorite = Ext.clone(pt.layout);
 
 				// Server sync
 				favorite.totals = favorite.showTotals;
@@ -1072,103 +1079,7 @@
 				delete favorite.organisationUnit;
 				delete favorite.parentOrganisationUnit;
 
-				// Dimensions
-				for (var i = 0, obj, key, items; i < pt.xLayout.objects.length; i++) {
-					obj = pt.xLayout.objects[i];
-
-					if (obj.objectName === pt.conf.finals.dimension.period.objectName) {
-						for (var j = 0, item; j < obj.items.length; j++) {
-							item = obj.items[j];
-
-							if (pt.conf.period.relativePeriodValueKeys[item]) {
-								key = pt.conf.finals.dimension.relativePeriod.value;
-
-								if (!favorite[key]) {
-									favorite[key] = {};
-								}
-
-								favorite[key][pt.conf.period.relativePeriodValueKeys[item]] = true;
-							}
-							else {
-								key = pt.conf.finals.dimension.fixedPeriod.value;
-
-								if (!favorite[key]) {
-									favorite[key] = [];
-								}
-
-								favorite[key].push({
-									id: item
-								});
-							}
-						}
-					}
-					else if (obj.objectName === pt.conf.finals.dimension.organisationUnitGroupSet.objectName ||
-							 obj.objectName === pt.conf.finals.dimension.dataElementGroupSet.objectName) {
-						key = pt.conf.finals.dimension.objectNameMap[obj.objectName].value;
-
-						if (!favorite[key]) {
-							favorite[key] = {};
-						}
-
-						favorite[key][obj.dimensionName] = [];
-
-						for (var j = 0, item; j < obj.items.length; j++) {
-							item = obj.items[j];
-
-							favorite[key][obj.dimensionName].push({
-								id: item
-							});
-						}
-					}
-					else {
-						key = pt.conf.finals.dimension.objectNameMap[obj.objectName].value;
-						favorite[key] = [];
-
-						for (var j = 0, item; j < obj.items.length; j++) {
-							item = obj.items[j];
-
-							favorite[key].push({
-								id: item
-							});
-						}
-					}
-				}
-
-				// Relative periods PUT workaround
-				if (!favorite.relativePeriods) {
-					favorite.relativePeriods = {};
-				}
-
-				// Layout
-				if (pt.xLayout.col) {
-					var a = [];
-
-					for (var i = 0; i < pt.xLayout.col.length; i++) {
-						a.push(pt.xLayout.col[i].dimensionName);
-					}
-
-					favorite.columnDimensions = a;
-				}
-
-				if (pt.xLayout.row) {
-					var a = [];
-
-					for (var i = 0; i < pt.xLayout.row.length; i++) {
-						a.push(pt.xLayout.row[i].dimensionName);
-					}
-
-					favorite.rowDimensions = a;
-				}
-
-				if (pt.xLayout.filter) {
-					var a = [];
-
-					for (var i = 0; i < pt.xLayout.filter.length; i++) {
-						a.push(pt.xLayout.filter[i].dimensionName);
-					}
-
-					favorite.filterDimensions = a;
-				}
+				delete favorite.parentGraphMap;
 			}
 
 			return favorite;
@@ -1196,7 +1107,7 @@
 				text: PT.i18n.create,
 				handler: function() {
 					var favorite = getBody();
-					favorite.name = nameTextfield.getValue	();
+					favorite.name = nameTextfield.getValue();
 
 					if (favorite && favorite.name) {
 						Ext.Ajax.request({
@@ -1921,8 +1832,8 @@
 				userOrganisationUnitChildren,
 				treePanel,
 				organisationUnit,
-				groupSetIdAvailableStoreMap = {},
-				groupSetIdSelectedStoreMap = {},
+				dimensionIdAvailableStoreMap = {},
+				dimensionIdSelectedStoreMap = {},
 				getGroupSetPanels,
 				validateSpecialCases,
 				update,
@@ -2025,18 +1936,17 @@
 				xtype: 'panel',
 				title: '<div class="pt-panel-title-data">' + PT.i18n.indicators + '</div>',
 				hideCollapseTool: true,
-				getData: function() {
-					var data = {
-						dimensionName: pt.conf.finals.dimension.indicator.dimensionName,
-						objectName: pt.conf.finals.dimension.indicator.objectName,
+				getDimension: function() {
+					var config = {
+						dimension: pt.conf.finals.dimension.indicator.objectName,
 						items: []
 					};
 
 					pt.store.indicatorSelected.each( function(r) {
-						data.items.push(r.data.id);
+						config.items.push({id: r.data.id});
 					});
 
-					return data.items.length ? data : null;
+					return config.items.length ? config : null;
 				},
 				onExpand: function() {
 					var h = pt.viewport.westRegion.hasScrollbar ?
@@ -2214,18 +2124,17 @@
 				xtype: 'panel',
 				title: '<div class="pt-panel-title-data">' + PT.i18n.data_elements + '</div>',
 				hideCollapseTool: true,
-				getData: function() {
-					var data = {
-						dimensionName: pt.conf.finals.dimension.dataElement.dimensionName,
-						objectName: pt.conf.finals.dimension.dataElement.objectName,
+				getDimension: function() {
+					var config = {
+						dimension: pt.conf.finals.dimension.dataElement.objectName,
 						items: []
 					};
 
 					pt.store.dataElementSelected.each( function(r) {
-						data.items.push(r.data.id);
+						config.items.push({id: r.data.id});
 					});
 
-					return data.items.length ? data : null;
+					return config.items.length ? config : null;
 				},
 				onExpand: function() {
 					var h = pt.viewport.westRegion.hasScrollbar ?
@@ -2403,18 +2312,17 @@
 				xtype: 'panel',
 				title: '<div class="pt-panel-title-data">' + PT.i18n.reporting_rates + '</div>',
 				hideCollapseTool: true,
-				getData: function() {
-					var data = {
-						dimensionName: pt.conf.finals.dimension.dataSet.dimensionName,
-						objectName: pt.conf.finals.dimension.dataSet.objectName,
+				getDimension: function() {
+					var config = {
+						dimension: pt.conf.finals.dimension.dataSet.objectName,
 						items: []
 					};
 
 					pt.store.dataSetSelected.each( function(r) {
-						data.items.push(r.data.id);
+						config.items.push({id: r.data.id});
 					});
 
-					return data.items.length ? data : null;
+					return config.items.length ? config : null;
 				},
 				onExpand: function() {
 					var h = pt.viewport.westRegion.hasScrollbar ?
@@ -2870,25 +2778,24 @@
 				xtype: 'panel',
 				title: '<div class="pt-panel-title-period">Periods</div>',
 				hideCollapseTool: true,
-				getData: function() {
-					var data = {
-							dimensionName: pt.conf.finals.dimension.period.dimensionName,
-							objectName: pt.conf.finals.dimension.period.objectName,
+				getDimension: function() {
+					var config = {
+							dimension: pt.conf.finals.dimension.period.objectName,
 							items: []
 						},
 						chb = pt.cmp.dimension.relativePeriod.checkbox;
 
 					pt.store.fixedPeriodSelected.each( function(r) {
-						data.items.push(r.data.id);
+						config.items.push({id: r.data.id});
 					});
 
 					for (var i = 0; i < chb.length; i++) {
 						if (chb[i].getValue()) {
-							data.items.push(chb[i].relativePeriodId);
+							config.items.push({id: chb[i].relativePeriodId});
 						}
 					}
 
-					return data.items.length ? data : null;
+					return config.items.length ? config : null;
 				},
 				onExpand: function() {
 					var h = pt.viewport.westRegion.hasScrollbar ?
@@ -3165,19 +3072,28 @@
 				bodyStyle: 'padding-top:5px',
 				hideCollapseTool: true,
 				collapsed: false,
-				getData: function() {
-					var records = treePanel.getSelectionModel().getSelection(),
-						data = {
-							dimensionName: pt.conf.finals.dimension.organisationUnit.dimensionName,
-							objectName: pt.conf.finals.dimension.organisationUnit.objectName,
+				getDimension: function() {
+					var r = treePanel.getSelectionModel().getSelection(),
+						config = {
+							dimension: pt.conf.finals.dimension.organisationUnit.objectName,
 							items: []
 						};
 
-					for (var i = 0; i < records.length; i++) {
-						data.items.push(records[i].data.id);
+					if (userOrganisationUnit.getValue() || userOrganisationUnitChildren.getValue()) {
+						if (userOrganisationUnit.getValue()) {
+							config.items.push({id: 'USER_ORGUNIT'});
+						}
+						if (userOrganisationUnitChildren.getValue()) {
+							config.items.push({id: 'USER_ORGUNIT_CHILDREN'});
+						}
+					}
+					else {
+						for (var i = 0; i < r.length; i++) {
+							config.items.push({id: r[i].data.id});
+						}
 					}
 
-					return data.items.length ? data : null;
+					return config.items.length ? config : null;
 				},
 				onExpand: function() {
 					var h = pt.viewport.westRegion.hasScrollbar ?
@@ -3206,33 +3122,39 @@
 				}
 			};
 
-			getGroupSetPanels = function(groupSets, objectName, iconCls) {
+			getDimensionPanels = function(dimensions, iconCls) {
 				var	getAvailableStore,
 					getSelectedStore,
 
 					createPanel,
 					getPanels;
 
-				getAvailableStore = function(groupSet) {
+				getAvailableStore = function(dimension) {
 					return Ext.create('Ext.data.Store', {
 						fields: ['id', 'name'],
-						data: groupSet.items,
+						proxy: {
+							type: 'ajax',
+							url: pt.baseUrl + '/api/dimensions/' + dimension.id + '.json',
+							reader: {
+								type: 'json',
+								root: 'items'
+							}
+						},
 						isLoaded: false,
 						storage: {},
 						sortStore: function() {
 							this.sort('name', 'ASC');
 						},
-						reload: function() {
-							this.removeAll();
-							this.storage = {};
-							this.loadData(groupSet.items);
+						reset: function() {
+							if (this.isLoaded) {
+								this.removeAll();
+								pt.util.store.loadFromStorage(this);
+								this.sortStore();
+							}
 						},
 						listeners: {
 							load: function(s) {
 								s.isLoaded = true;
-								//s.each( function(r) {
-									//r.data.name = pt.conf.util.jsonEncodeString(r.data.name);
-								//});
 								pt.util.store.addToStorage(s);
 							}
 						}
@@ -3246,7 +3168,7 @@
 					});
 				};
 
-				createPanel = function(groupSet) {
+				createPanel = function(dimension) {
 					var getAvailable,
 						getSelected,
 
@@ -3340,11 +3262,11 @@
 						});
 					};
 
-					availableStore = getAvailableStore(groupSet);
+					availableStore = getAvailableStore(dimension);
 					selectedStore = getSelectedStore();
 
-					groupSetIdAvailableStoreMap[groupSet.id] = availableStore;
-					groupSetIdSelectedStoreMap[groupSet.id] = selectedStore;
+					dimensionIdAvailableStoreMap[dimension.id] = availableStore;
+					dimensionIdSelectedStoreMap[dimension.id] = selectedStore;
 
 					available = getAvailable(availableStore);
 					selected = getSelected(selectedStore);
@@ -3355,20 +3277,21 @@
 
 					panel = {
 						xtype: 'panel',
-						title: '<div class="' + iconCls + '">' + groupSet.name + '</div>',
+						title: '<div class="' + iconCls + '">' + dimension.name + '</div>',
 						hideCollapseTool: true,
-						getData: function() {
-							var data = {
-								dimensionName: groupSet.id,
-								objectName: objectName,
+						availableStore: availableStore,
+						selectedStore: selectedStore,
+						getDimension: function() {
+							var config = {
+								dimension: dimension.id,
 								items: []
 							};
 
 							selectedStore.each( function(r) {
-								data.items.push(r.data.id);
+								config.items.push({id: r.data.id});
 							});
 
-							return data.items.length ? data : null;
+							return config.items.length ? config : null;
 						},
 						onExpand: function() {
 							if (!availableStore.isLoaded) {
@@ -3410,14 +3333,10 @@
 				};
 
 				getPanels = function() {
-					var panels = [],
-						groupSet,
-						last;
-
-					for (var i = 0, panel; i < groupSets.length; i++) {
-						groupSet = groupSets[i];
-
-						panel = createPanel(groupSet);
+					var panels = [];
+
+					for (var i = 0, panel; i < dimensions.length; i++) {
+						panel = createPanel(dimensions[i]);
 
 						panels.push(panel);
 					}
@@ -3429,58 +3348,57 @@
 			};
 
 			validateSpecialCases = function(layout) {
-				var dimConf = pt.conf.finals.dimension,
-					dimensionNames = [],
-					layoutObjects = [].concat(Ext.clone(layout.col || []), Ext.clone(layout.row || []), Ext.clone(layout.filter || []));
+				var dimConf = pt.conf.finals.dimension;
+					//dimensionNames = [],
+					//layoutObjects = [].concat(Ext.clone(layout.columns || []), Ext.clone(layout.rows || []), Ext.clone(layout.filters || []));
 
 				// Layout names
-				for (var i = 0; i < layoutObjects.length; i++) {
-					dimensionNames.push(layoutObjects[i].dimensionName);
+				//for (var i = 0; i < layoutObjects.length; i++) {
+					//dimensionNames.push(layoutObjects[i].dimension);
+				//}
+				if (!layout) {
+					return;
 				}
 
-				// Indicator as filter
-				if (layout.filter && pt.store.indicatorSelected.data.length) {
-					for (var i = 0; i < layout.filter.length; i++) {
-						if (layout.filter[i].dimensionName === dimConf.data.dimensionName) {
+				if (layout.filters && layout.filters.length) {
+					for (var i = 0; i < layout.filters.length; i++) {
+
+						// Indicators as filter
+						if (layout.filters[i].dimension === dimConf.indicator.objectName) {
 							alert(PT.i18n.indicators_cannot_be_specified_as_filter);
 							return;
 						}
+
+						// Categories as filter
+						if (layout.filters[i].dimension === dimConf.category.objectName) {
+							alert(PT.i18n.categories_cannot_be_specified_as_filter);
+							return;
+						}
 					}
 				}
 
-				// Categories as filter
-				if (layout.filter && pt.viewport.layoutWindow.filterStore.getById(dimConf.category.dimensionName)) {
-					alert(PT.i18n.categories_cannot_be_specified_as_filter);
-					return;
-				}
-
 				// Degs and datasets in the same query
-				if (Ext.Array.contains(dimensionNames, dimConf.data.dimensionName) && pt.store.dataSetSelected.data.length) {
-					for (var i = 0; i < pt.init.degs.length; i++) {
-						if (Ext.Array.contains(dimensionNames, pt.init.degs[i].id)) {
-							alert(PT.i18n.data_element_group_sets_cannot_be_specified_together_with_data_sets);
-							return;
-						}
-					}
-				}
+				//if (Ext.Array.contains(dimensionNames, dimConf.data.dimensionName) && pt.store.dataSetSelected.data.length) {
+					//for (var i = 0; i < pt.init.degs.length; i++) {
+						//if (Ext.Array.contains(dimensionNames, pt.init.degs[i].id)) {
+							//alert(PT.i18n.data_element_group_sets_cannot_be_specified_together_with_data_sets);
+							//return;
+						//}
+					//}
+				//}
 
 				return true;
 			};
 
 			update = function() {
 				var config = pt.util.pivot.getLayoutConfig(),
-					layout = pt.api.Layout(config);
+				layout = pt.api.layout.Layout(config);
 
-				if (!layout) {
-					return;
-				}
 				if (!validateSpecialCases(layout)) {
 					return;
 				}
 
-				if (layout) {
-					pt.util.pivot.createTable(layout, pt);
-				}
+				pt.util.pivot.createTable(layout, pt);
 			};
 
 			accordionBody = Ext.create('Ext.panel.Panel', {
@@ -3497,14 +3415,11 @@
 						period,
 						organisationUnit
 					],
-					ougs = Ext.clone(pt.init.ougs),
-					degs = Ext.clone(pt.init.degs);
-
-					pt.util.array.sortObjectsByString(ougs);
-					pt.util.array.sortObjectsByString(degs);
-
-					panels = panels.concat(getGroupSetPanels(ougs, pt.conf.finals.dimension.organisationUnitGroupSet.objectName, 'pt-panel-title-organisationunitgroupset'));
-					panels = panels.concat(getGroupSetPanels(degs, pt.conf.finals.dimension.dataElementGroupSet.objectName, 'pt-panel-title-dataelementgroupset'));
+					dims = Ext.clone(pt.init.dimensions);
+
+					pt.util.array.sortObjectsByString(dims);
+
+					panels = panels.concat(getDimensionPanels(dims, 'pt-panel-title-dimension'));
 
 					last = panels[panels.length - 1];
 					last.cls = 'pt-accordion-last';
@@ -3722,77 +3637,79 @@
 				}
 			});
 
-			setFavorite = function(r) {
+			setFavorite = function(layout) {
+				var dimConf = pt.conf.finals.dimension,
+					xLayout,
+					dimMap,
+					recMap,
+					objectName,
+					periodRecords,
+					fixedPeriodRecords = [],
+					isOu = false,
+					isOuc = false;
+
+				pt.util.pivot.createTable(layout, pt);
+
+				xLayout = pt.util.pivot.getExtendedLayout(layout);
+				dimMap = xLayout.objectNameDimensionsMap;
+				recMap = xLayout.objectNameItemsMap;
+				graphMap = layout.parentGraphMap;
 
 				// Indicators
 				pt.store.indicatorSelected.removeAll();
-				if (Ext.isArray(r.indicators)) {
-					pt.store.indicatorSelected.add(r.indicators);
+				objectName = dimConf.indicator.objectName;
+				if (dimMap[objectName]) {
+					pt.store.indicatorSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.indicatorAvailable}, {store: pt.store.indicatorSelected});
 				}
 
 				// Data elements
 				pt.store.dataElementSelected.removeAll();
-				if (Ext.isArray(r.dataElements)) {
-					pt.store.dataElementSelected.add(r.dataElements);
+				objectName = dimConf.dataElement.objectName;
+				if (dimMap[objectName]) {
+					pt.store.dataElementSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.dataElementAvailable}, {store: pt.store.dataElementSelected});
 				}
 
 				// Data sets
 				pt.store.dataSetSelected.removeAll();
-				if (Ext.isArray(r.dataSets)) {
-					pt.store.dataSetSelected.add(r.dataSets);
+				objectName = dimConf.dataSet.objectName;
+				if (dimMap[objectName]) {
+					pt.store.dataSetSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.dataSetAvailable}, {store: pt.store.dataSetSelected});
 				}
 
-				// Fixed periods
+				// Periods
 				pt.store.fixedPeriodSelected.removeAll();
-				if (Ext.isArray(r.periods)) {
-					pt.store.fixedPeriodSelected.add(r.periods);
-				}
-
-				// Relative periods
-				if (Ext.isObject(r.relativePeriods)) {
-					for (var key in r.relativePeriods) {
-						if (r.relativePeriods.hasOwnProperty(key) && pt.conf.period.relativePeriodParamKeys.hasOwnProperty(key)) {
-							var value = pt.conf.period.relativePeriodParamKeys[key];
-							relativePeriod.valueComponentMap[value].setValue(!!r.relativePeriods[key]);
-						}
-					}
-				}
-
-				// Organisation units: tree sync/async
-
-				// User orgunit
-				userOrganisationUnit.setValue(r.userOrganisationUnit);
-				userOrganisationUnitChildren.setValue(r.userOrganisationUnitChildren);
-
-				// Reset groupset stores
-				for (var key in groupSetIdSelectedStoreMap) {
-					if (groupSetIdSelectedStoreMap.hasOwnProperty(key)) {
-						var a = groupSetIdAvailableStoreMap[key],
-							s = groupSetIdSelectedStoreMap[key];
+				pt.util.checkbox.setAllFalse();
+				periodRecords = recMap[dimConf.period.objectName] || [];
+				for (var i = 0, peroid, checkbox; i < periodRecords.length; i++) {
+					period = periodRecords[i];
+					checkbox = relativePeriod.valueComponentMap[period.id];
+					if (checkbox) {
+						checkbox.setValue(true);
+					}
+					else {
+						fixedPeriodRecords.push(period);
+					}
+				}
+				pt.store.fixedPeriodSelected.add(fixedPeriodRecords);
+				pt.util.multiselect.filterAvailable({store: pt.store.fixedPeriodAvailable}, {store: pt.store.fixedPeriodSelected});
+
+				// Group sets
+				for (var key in dimensionIdSelectedStoreMap) {
+					if (dimensionIdSelectedStoreMap.hasOwnProperty(key)) {
+						var a = dimensionIdAvailableStoreMap[key],
+							s = dimensionIdSelectedStoreMap[key];
 
 						if (s.getCount() > 0) {
-							a.reload();
+							a.reset();
 							s.removeAll();
 						}
-					}
-				}
-
-				// Organisation unit group sets
-				if (Ext.isObject(r.organisationUnitGroupSets)) {
-					for (var key in r.organisationUnitGroupSets) {
-						if (r.organisationUnitGroupSets.hasOwnProperty(key)) {
-							groupSetIdSelectedStoreMap[key].add(r.organisationUnitGroupSets[key]);
-							pt.util.multiselect.filterAvailable({store: groupSetIdAvailableStoreMap[key]}, {store: groupSetIdSelectedStoreMap[key]});
-						}
-					}
-				}
-
-				// Data element group sets
-				if (Ext.isObject(r.dataElementGroupSets)) {
-					for (var key in r.dataElementGroupSets) {
-						if (r.dataElementGroupSets.hasOwnProperty(key)) {
-							groupSetIdSelectedStoreMap[key].add(r.dataElementGroupSets[key]);
-							pt.util.multiselect.filterAvailable({store: groupSetIdAvailableStoreMap[key]}, {store: groupSetIdSelectedStoreMap[key]});
+
+						if (recMap[key]) {
+							s.add(recMap[key]);
+							dv.util.multiselect.filterAvailable({store: a}, {store: s});
 						}
 					}
 				}
@@ -3803,9 +3720,9 @@
 				pt.viewport.rowStore.removeAll();
 				pt.viewport.filterStore.removeAll();
 
-				if (Ext.isArray(r.columnDimensions)) {
-					for (var i = 0, dim; i < r.columnDimensions.length; i++) {
-						dim = pt.conf.finals.dimension.objectNameMap[r.columnDimensions[i]];
+				if (layout.columns) {
+					for (var i = 0, dim; i < layout.columns.length; i++) {
+						dim = dimConf.objectNameMap[layout.columns[i].dimension];
 
 						pt.viewport.colStore.add({
 							id: dim.dimensionName,
@@ -3813,13 +3730,12 @@
 						});
 
 						pt.viewport.dimensionStore.remove(pt.viewport.dimensionStore.getById(dim.dimensionName));
-
 					}
 				}
 
-				if (Ext.isArray(r.rowDimensions)) {
-					for (var i = 0, dim; i < r.rowDimensions.length; i++) {
-						dim = pt.conf.finals.dimension.objectNameMap[r.rowDimensions[i]];
+				if (layout.rows) {
+					for (var i = 0, dim; i < layout.rows.length; i++) {
+						dim = dimConf.objectNameMap[layout.rows[i].dimension];
 
 						pt.viewport.rowStore.add({
 							id: dim.dimensionName,
@@ -3830,9 +3746,9 @@
 					}
 				}
 
-				if (Ext.isArray(r.filterDimensions)) {
-					for (var i = 0, dim; i < r.filterDimensions.length; i++) {
-						dim = pt.conf.finals.dimension.objectNameMap[r.filterDimensions[i]];
+				if (layout.filters) {
+					for (var i = 0, dim; i < layout.filters.length; i++) {
+						dim = dimConf.objectNameMap[layout.filters[i].dimension];
 
 						pt.viewport.filterStore.add({
 							id: dim.dimensionName,
@@ -3844,42 +3760,35 @@
 				}
 
 				// Options
-				pt.viewport.showTotals.setValue(r.totals);
-				pt.viewport.showSubTotals.setValue(r.subtotals);
-				pt.viewport.hideEmptyRows.setValue(r.hideEmptyRows);
-				pt.viewport.displayDensity.setValue(r.displayDensity);
-				pt.viewport.fontSize.setValue(r.fontSize);
-				pt.viewport.digitGroupSeparator.setValue(r.digitGroupSeparator);
-
-				if (Ext.isObject(r.reportParams)) {
-					pt.viewport.reportingPeriod.setValue(r.reportParams.paramReportingPeriod);
-					pt.viewport.organisationUnit.setValue(r.reportParams.paramOrganisationUnit);
-					pt.viewport.parentOrganisationUnit.setValue(r.reportParams.paramParentOrganisationUnit);
-				}
-
-				// Upgrade fixes
-				if (!Ext.isArray(r.organisationUnits) || !r.organisationUnits.length) {
-					if (Ext.isObject(r.reportParams) && r.reportParams.paramOrganisationUnit) {
-						userOrganisationUnit.setValue(true);
-					}
-
-					if (Ext.isObject(r.reportParams) && r.reportParams.paramParentOrganisationUnit) {
-						userOrganisationUnit.setValue(true);
-					}
-				}
-
-				// Organisation units: If fav has organisation units, execute from tree callback instead
-				if (Ext.isArray(r.organisationUnits) && Ext.isObject(r.parentGraphMap)) {
-					treePanel.numberOfRecords = pt.util.object.getLength(r.parentGraphMap);
-					for (var key in r.parentGraphMap) {
-						if (r.parentGraphMap.hasOwnProperty(key)) {
-							treePanel.multipleExpand(key, r.parentGraphMap[key], true);
+				pt.viewport.optionsWindow.setOptions(layout);
+
+				// Organisation units
+				if (recMap[dimConf.organisationUnit.objectName]) {
+					for (var i = 0, ouRecords = recMap[dimConf.organisationUnit.objectName]; i < ouRecords.length; i++) {
+						if (ouRecords[i].id === 'USER_ORGUNIT') {
+							isOu = true;
+						}
+						if (ouRecords[i].id === 'USER_ORGUNIT_CHILDREN') {
+							isOuc = true;
+						}
+					}
+				}
+
+				userOrganisationUnit.setValue(isOu);
+				userOrganisationUnitChildren.setValue(isOuc);
+
+				// If fav has organisation units, wait for tree callback before update
+				if (recMap[dimConf.organisationUnit.objectName] && graphMap) {
+					treePanel.numberOfRecords = pt.util.object.getLength(graphMap);
+					for (var key in graphMap) {
+						if (graphMap.hasOwnProperty(key)) {
+							treePanel.multipleExpand(key, graphMap[key], true);
 						}
 					}
 				}
 				else {
 					treePanel.reset();
-					update();
+					//update();
 				}
 			};
 
@@ -3951,5 +3860,6 @@
 		url: pt.conf.finals.ajax.path_pivot + 'initialize.action',
 		success: function(r) {
 			PT.app.init.onInitialize(r);
-	}});
+		}
+	});
 });

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-04-30 14:46:15 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-05-22 14:00:22 +0000
@@ -4,7 +4,7 @@
 
 PT.core.getConfigs = function() {
 	var conf = {},
-		dim;
+		dimConf;
 
 	conf.finals = {
         ajax: {
@@ -61,6 +61,12 @@
                 dimensionName: 'dx',
                 objectName: 'de'
             },
+            operand: {
+				value: 'operand',
+				name: 'Operand',
+				dimensionName: 'dx',
+				objectName: 'dc'
+			},
             dataSet: {
 				value: 'dataSets',
                 name: PT.i18n.data_sets,
@@ -71,10 +77,7 @@
                 value: 'period',
                 name: PT.i18n.periods,
                 dimensionName: 'pe',
-                objectName: 'pe',
-                warning: {
-					filter: '...'//PT.i18n.wm_multiple_filter_period
-				}
+                objectName: 'pe'
             },
             fixedPeriod: {
 				value: 'periods'
@@ -86,18 +89,11 @@
                 value: 'organisationUnits',
                 name: PT.i18n.organisation_units,
                 dimensionName: 'ou',
-                objectName: 'ou',
-                warning: {
-					filter: '...'//PT.i18n.wm_multiple_filter_orgunit
-				}
+                objectName: 'ou'
             },
-            organisationUnitGroupSet: {
-				value: 'organisationUnitGroupSets',
-				objectName: 'ougs'
-			},
-            dataElementGroupSet: {
-				value: 'dataElementGroupSets',
-				objectName: 'degs'
+            dimension: {
+				value: 'dimension'
+				//objectName: 'di'
 			},
 			value: {
 				value: 'value'
@@ -108,18 +104,18 @@
 		}
 	};
 
-	dim = conf.finals.dimension;
+	dimConf = conf.finals.dimension;
 
-	dim.objectNameMap = {};
-	dim.objectNameMap[dim.data.objectName] = dim.data;
-	dim.objectNameMap[dim.indicator.objectName] = dim.indicator;
-	dim.objectNameMap[dim.dataElement.objectName] = dim.dataElement;
-	dim.objectNameMap[dim.dataSet.objectName] = dim.dataSet;
-	dim.objectNameMap[dim.category.objectName] = dim.category;
-	dim.objectNameMap[dim.period.objectName] = dim.period;
-	dim.objectNameMap[dim.organisationUnit.objectName] = dim.organisationUnit;
-	dim.objectNameMap[dim.organisationUnitGroupSet.objectName] = dim.organisationUnitGroupSet;
-	dim.objectNameMap[dim.dataElementGroupSet.objectName] = dim.dataElementGroupSet;
+	dimConf.objectNameMap = {};
+	dimConf.objectNameMap[dimConf.data.objectName] = dimConf.data;
+	dimConf.objectNameMap[dimConf.indicator.objectName] = dimConf.indicator;
+	dimConf.objectNameMap[dimConf.dataElement.objectName] = dimConf.dataElement;
+	dimConf.objectNameMap[dimConf.operand.objectName] = dimConf.operand;
+	dimConf.objectNameMap[dimConf.dataSet.objectName] = dimConf.dataSet;
+	dimConf.objectNameMap[dimConf.category.objectName] = dimConf.category;
+	dimConf.objectNameMap[dimConf.period.objectName] = dimConf.period;
+	dimConf.objectNameMap[dimConf.organisationUnit.objectName] = dimConf.organisationUnit;
+	dimConf.objectNameMap[dimConf.dimension.objectName] = dimConf.dimension;
 
 	conf.period = {
 		relativePeriods: {
@@ -447,12 +443,16 @@
 				return 0;
 			});
 
-			// Sort object items order
+			// Sort object items, ids
 			for (var i = 0, dim; i < dimensions.length; i++) {
 				dim = dimensions[i];
 
 				if (dim.items) {
-					dimensions[i].items.sort();
+					dimensions[i].items = util.array.sortDimensions(dim.items, 'id');
+				}
+
+				if (dim.ids) {
+					dimensions[i].ids = dim.ids.sort();
 				}
 			}
 
@@ -507,91 +507,221 @@
 	};
 
 	util.pivot = {
-		createTable: function(settings, pt) {
-			var options = settings.options,
-				extendLayout,
+		getExtendedLayout: function(layout) {
+			var dimConf = pt.conf.finals.dimension,
+				layout = Ext.clone(layout),
+				xLayout = {
+					columns: [],
+					rows: [],
+					filters: [],
+
+					columnObjectNames: [],
+					columnDimensionNames: [],
+					rowObjectNames: [],
+					rowDimensionNames: [],
+
+					// Axis
+					axisDimensions: [],
+					axisObjectNames: [],
+					axisDimensionNames: [],
+
+						// For param string
+					sortedAxisDimensionNames: [],
+
+					// Filter
+					filterDimensions: [],
+					filterObjectNames: [],
+					filterDimensionNames: [],
+
+						// For param string
+					sortedFilterDimensions: [],
+
+					// All
+					dimensions: [],
+					objectNames: [],
+					dimensionNames: [],
+
+					// Object name maps
+					objectNameDimensionsMap: {},
+					objectNameItemsMap: {},
+					objectNameIdsMap: {},
+
+					// Dimension name maps
+					dimensionNameDimensionsMap: {},
+					dimensionNameItemsMap: {},
+					dimensionNameIdsMap: {},
+
+						// For param string
+					dimensionNameSortedIdsMap: {}
+				};
+
+			// Columns, rows, filters
+			if (layout.columns) {
+				for (var i = 0, dim, items, xDim; i < layout.columns.length; i++) {
+					dim = layout.columns[i];
+					items = dim.items;
+					xDim = {};
+
+					xDim.dimension = dim.dimension;
+					xDim.objectName = dim.dimension;
+					xDim.dimensionName = dimConf.objectNameMap[dim.dimension].dimensionName;
+
+					if (items) {
+						xDim.items = items;
+						xDim.ids = [];
+
+						for (var j = 0; j < items.length; j++) {
+							xDim.ids.push(items[j].id);
+						}
+					}
+
+					xLayout.columns.push(xDim);
+
+					xLayout.columnObjectNames.push(xDim.objectName);
+					xLayout.columnDimensionNames.push(xDim.dimensionName);
+
+					xLayout.axisDimensions.push(xDim);
+					xLayout.axisObjectNames.push(xDim.objectName);
+					xLayout.axisDimensionNames.push(dimConf.objectNameMap[xDim.objectName].dimensionName);
+
+					xLayout.objectNameDimensionsMap[xDim.objectName] = xDim;
+					xLayout.objectNameItemsMap[xDim.objectName] = xDim.items;
+					xLayout.objectNameIdsMap[xDim.objectName] = xDim.ids;
+				}
+			}
+
+			if (layout.rows) {
+				for (var i = 0, dim, items, xDim; i < layout.rows.length; i++) {
+					dim = layout.rows[i];
+					items = dim.items;
+					xDim = {};
+
+					xDim.dimension = dim.dimension;
+					xDim.objectName = dim.dimension;
+					xDim.dimensionName = dimConf.objectNameMap[dim.dimension].dimensionName;
+
+					if (items) {
+						xDim.items = items;
+						xDim.ids = [];
+
+						for (var j = 0; j < items.length; j++) {
+							xDim.ids.push(items[j].id);
+						}
+					}
+
+					xLayout.rows.push(xDim);
+
+					xLayout.rowObjectNames.push(xDim.objectName);
+					xLayout.rowDimensionNames.push(xDim.dimensionName);
+
+					xLayout.axisDimensions.push(xDim);
+					xLayout.axisObjectNames.push(xDim.objectName);
+					xLayout.axisDimensionNames.push(dimConf.objectNameMap[xDim.objectName].dimensionName);
+
+					xLayout.objectNameDimensionsMap[xDim.objectName] = xDim;
+					xLayout.objectNameItemsMap[xDim.objectName] = xDim.items;
+					xLayout.objectNameIdsMap[xDim.objectName] = xDim.ids;
+				}
+			}
+
+			if (layout.filters) {
+				for (var i = 0, dim, items, xDim; i < layout.filters.length; i++) {
+					dim = layout.filters[i];
+					items = dim.items;
+					xDim = {};
+
+					xDim.dimension = dim.dimension;
+					xDim.objectName = dim.dimension;
+					xDim.dimensionName = dimConf.objectNameMap[dim.dimension].dimensionName;
+
+					if (items) {
+						xDim.items = items;
+						xDim.ids = [];
+
+						for (var j = 0; j < items.length; j++) {
+							xDim.ids.push(items[j].id);
+						}
+					}
+
+					xLayout.filters.push(xDim);
+
+					xLayout.filterDimensions.push(xDim);
+					xLayout.filterObjectNames.push(xDim.objectName);
+					xLayout.filterDimensionNames.push(dimConf.objectNameMap[xDim.objectName].dimensionName);
+
+					xLayout.objectNameDimensionsMap[xDim.objectName] = xDim;
+					xLayout.objectNameItemsMap[xDim.objectName] = xDim.items;
+					xLayout.objectNameIdsMap[xDim.objectName] = xDim.ids;
+				}
+			}
+
+			// Unique dimension names
+			xLayout.axisDimensionNames = Ext.Array.unique(xLayout.axisDimensionNames);
+			xLayout.filterDimensionNames = Ext.Array.unique(xLayout.filterDimensionNames);
+
+			xLayout.columnDimensionNames = Ext.Array.unique(xLayout.columnDimensionNames);
+			xLayout.rowDimensionNames = Ext.Array.unique(xLayout.rowDimensionNames);
+			xLayout.filterDimensionNames = Ext.Array.unique(xLayout.filterDimensionNames);
+
+				// For param string
+			xLayout.sortedAxisDimensionNames = Ext.clone(xLayout.axisDimensionNames).sort();
+			xLayout.sortedFilterDimensions = pt.util.array.sortDimensions(Ext.clone(xLayout.filterDimensions));
+
+			// All
+			xLayout.dimensions = [].concat(xLayout.axisDimensions, xLayout.filterDimensions);
+			xLayout.objectNames = [].concat(xLayout.axisObjectNames, xLayout.filterObjectNames);
+			xLayout.dimensionNames = [].concat(xLayout.axisDimensionNames, xLayout.filterDimensionNames);
+
+			// Dimension name maps
+			for (var i = 0, dimName; i < xLayout.dimensionNames.length; i++) {
+				dimName = xLayout.dimensionNames[i];
+
+				xLayout.dimensionNameDimensionsMap[dimName] = [];
+				xLayout.dimensionNameItemsMap[dimName] = [];
+				xLayout.dimensionNameIdsMap[dimName] = [];
+			}
+
+			for (var i = 0, xDim; i < xLayout.dimensions.length; i++) {
+				xDim = xLayout.dimensions[i];
+
+				xLayout.dimensionNameDimensionsMap[xDim.dimensionName].push(xDim);
+				xLayout.dimensionNameItemsMap[xDim.dimensionName] = xLayout.dimensionNameItemsMap[xDim.dimensionName].concat(xDim.items);
+				xLayout.dimensionNameIdsMap[xDim.dimensionName] = xLayout.dimensionNameIdsMap[xDim.dimensionName].concat(xDim.ids);
+			}
+
+				// For param string
+			for (var key in xLayout.dimensionNameIdsMap) {
+				if (xLayout.dimensionNameIdsMap.hasOwnProperty(key)) {
+					xLayout.dimensionNameSortedIdsMap[key] = Ext.clone(xLayout.dimensionNameIdsMap[key]).sort();
+				}
+			}
+
+			return xLayout;
+		},
+
+		createTable: function(layout, pt) {
+			var dimConf = pt.conf.finals.dimension,
 				getSyncronizedXLayout,
 				getParamString,
-				validateResponse,
-				extendResponse,
-				extendAxis,
+				getExtendedResponse,
+				getExtendedAxis,
 				validateUrl,
 				getTableHtml,
-				initialize,
-
-				dimConf = pt.conf.finals.dimension;
-
-			extendLayout = function(settings) {
-				var xLayout = Ext.clone(settings),
-					addDimensions,
-					addDimensionNames,
-					addSortedDimensions,
-					addSortedFilterDimensions;
-
-				addDimensions = function() {
-					xLayout.dimensions = [].concat(Ext.clone(xLayout.col) || [], Ext.clone(xLayout.row) || []);
-				}();
-
-				addDimensionNames = function() {
-					var a = [],
-						dimensions = Ext.clone(xLayout.dimensions) || [];
-
-					for (var i = 0; i < dimensions.length; i++) {
-						a.push(dimensions[i].dimensionName);
-					}
-
-					xLayout.dimensionNames = a;
-				}();
-
-				addSortedDimensions = function() {
-					xLayout.sortedDimensions = pt.util.array.sortDimensions(Ext.clone(xLayout.dimensions) || []);
-				}();
-
-				addSortedFilterDimensions = function() {
-						xLayout.sortedFilterDimensions = pt.util.array.sortDimensions(Ext.clone(xLayout.filter) || []);
-				}();
-
-				addNameItemsMap = function() {
-					var map = {},
-						dimensions = Ext.clone(xLayout.dimensions) || [];
-
-					for (var i = 0, dim; i < dimensions.length; i++) {
-						dim = dimensions[i];
-
-						map[dim.dimensionName] = dim.items || [];
-					}
-
-					xLayout.nameItemsMap = map;
-				}();
-
-				return xLayout;
-			};
+				initialize;
 
 			getSyncronizedXLayout = function(xLayout, response) {
-				var getHeaderNames,
-
-					headerNames,
-					newLayout;
-
-				getHeaderNames = function() {
-					var a = [];
-
-					for (var i = 0; i < response.headers.length; i++) {
-						a.push(response.headers[i].name);
-					}
-
-					return a;
-				};
-
-				removeDimensionFromLayout = function(dimensionName) {
-					var getCleanAxis;
-
-					getAxis = function(axis) {
-						var axis = Ext.clone(axis),
-							dimension;
+				var removeDimensionFromXLayout,
+					getHeaderNames;
+
+				removeDimensionFromXLayout = function(objectName) {
+					var getUpdatedAxis;
+
+					getUpdatedAxis = function(axis) {
+						var dimension;
+						axis = Ext.clone(axis);
 
 						for (var i = 0; i < axis.length; i++) {
-							if (axis[i].dimensionName === dimensionName) {
+							if (axis[i].dimension === objectName) {
 								dimension = axis[i];
 							}
 						}
@@ -603,93 +733,98 @@
 						return axis;
 					};
 
-					if (settings.col) {
-						settings.col = getAxis(settings.col);
-					}
-					if (settings.row) {
-						settings.row = getAxis(settings.row);
-					}
-					if (settings.filter) {
-						settings.filter = getAxis(settings.filter);
-					}
-				};
-
-				headerNames = getHeaderNames();
-
-				// remove co from settings if it does not exist in response
-				if (Ext.Array.contains(xLayout.dimensionNames, dimConf.category.dimensionName) && !(Ext.Array.contains(headerNames, dimConf.category.dimensionName))) {
-					removeDimensionFromLayout(dimConf.category.dimensionName);
-
-					newLayout = pt.api.Layout(settings);
-
-					if (!newLayout) {
-						return;
-					}
-
-					return extendLayout(newLayout);
-				}
-				else {
+					if (xLayout.columns) {
+						xLayout.columns = getUpdatedAxis(xLayout.columns);
+					}
+					if (xLayout.rows) {
+						xLayout.rows = getUpdatedAxis(xLayout.rows);
+					}
+					if (xLayout.filters) {
+						xLayout.filters = getUpdatedAxis(xLayout.filters);
+					}
+				};
+
+				getHeaderNames = function() {
+					var headerNames = [];
+
+					for (var i = 0; i < response.headers.length; i++) {
+						headerNames.push(response.headers[i].name);
+					}
+
+					return headerNames;
+				};
+
+				return function() {
+					var headerNames = getHeaderNames(),
+						co = dimConf.category.objectName,
+						layout;
+
+					// Remove co from layout if it does not exist in response
+					if (Ext.Array.contains(xLayout.axisDimensionNames, co) && !(Ext.Array.contains(headerNames, co))) {
+						removeDimensionFromXLayout(co);
+
+						layout = pt.api.layout.Layout(xLayout);
+
+						return layout ? pt.util.pivot.getExtendedLayout(layout) : null;
+					}
+
 					return xLayout;
-				}
+				}();
 			};
 
 			getParamString = function(xLayout) {
-				var sortedDimensions = xLayout.sortedDimensions,
+				var sortedAxisDimensionNames = xLayout.sortedAxisDimensionNames,
 					sortedFilterDimensions = xLayout.sortedFilterDimensions,
-					paramString = '?';
-
-				for (var i = 0, sortedDim; i < sortedDimensions.length; i++) {
-					sortedDim = sortedDimensions[i];
-
-					paramString += 'dimension=' + sortedDim.dimensionName;
-
-					if (sortedDim.dimensionName !== pt.conf.finals.dimension.category.dimensionName) {
-						paramString += ':' + sortedDim.items.join(';');
+					dimensionNameSortedIdsMap = xLayout.dimensionNameSortedIdsMap,
+					paramString = '?',
+					dimConf = pt.conf.finals.dimension,
+					addCategoryDimension = false,
+					map = xLayout.dimensionNameItemsMap,
+					dx = dimConf.indicator.dimensionName;
+
+				for (var i = 0, dimName, items; i < sortedAxisDimensionNames.length; i++) {
+					dimName = sortedAxisDimensionNames[i];
+
+					paramString += 'dimension=' + dimName;
+
+					items = Ext.clone(dimensionNameSortedIdsMap[dimName]);
+
+					if (dimName === dx) {
+						for (var j = 0, index; j < items.length; j++) {
+							index = items[j].indexOf('-');
+
+							if (index > 0) {
+								addCategoryDimension = true;
+								items[j] = items[j].substr(0, index);
+							}
+						}
+
+						items = Ext.Array.unique(items);
 					}
 
-					if (i < (sortedDimensions.length - 1)) {
+					paramString += ':' + items.join(';');
+
+					if (i < (sortedAxisDimensionNames.length - 1)) {
 						paramString += '&';
 					}
 				}
 
-				if (sortedFilterDimensions) {
-					for (var i = 0, sortedFilterDim; i < sortedFilterDimensions.length; i++) {
-						sortedFilterDim = sortedFilterDimensions[i];
-
-						paramString += '&filter=' + sortedFilterDim.dimensionName + ':' + sortedFilterDim.items.join(';');
+				if (addCategoryDimension) {
+					paramString += '&dimension=' + pt.conf.finals.dimension.category.dimensionName;
+				}
+
+				if (Ext.isArray(sortedFilterDimensions) && sortedFilterDimensions.length) {
+					for (var i = 0, dim; i < sortedFilterDimensions.length; i++) {
+						dim = sortedFilterDimensions[i];
+
+						paramString += '&filter=' + dim.dimensionName + ':' + dim.ids.join(';');
 					}
 				}
 
 				return paramString;
 			};
 
-			validateResponse = function(response) {
-				if (!(response && Ext.isObject(response))) {
-					alert('Data invalid');
-					return false;
-				}
-
-				if (!(response.headers && Ext.isArray(response.headers) && response.headers.length)) {
-					alert('Data invalid');
-					return false;
-				}
-
-				if (!(Ext.isNumber(response.width) && response.width > 0 &&
-					  Ext.isNumber(response.height) && response.height > 0 &&
-					  Ext.isArray(response.rows) && response.rows.length > 0)) {
-					alert('No values found');
-					return false;
-				}
-
-				if (response.headers.length !== response.rows[0].length) {
-					alert('Data invalid');
-					return false;
-				}
-
-				return true;
-			};
-
-			extendResponse = function(response, xLayout) {
+			getExtendedResponse = function(response, xLayout) {
 				response.nameHeaderMap = {};
 				response.idValueMap = {};
 
@@ -711,7 +846,7 @@
 								header.items = [].concat(response.metaData[pt.conf.finals.dimension.period.dimensionName]);
 							}
 							else {
-								header.items = xLayout.nameItemsMap[header.name];
+								header.items = xLayout.dimensionNameIdsMap[header.name];
 							}
 
 							header.size = header.items.length;
@@ -728,7 +863,7 @@
 
 				var createValueIds = function() {
 					var valueHeaderIndex = response.nameHeaderMap[pt.conf.finals.dimension.value.value].index,
-						dimensionNames = xLayout.dimensionNames,
+						dimensionNames = xLayout.axisDimensionNames,
 						idIndexOrder = [];
 
 					// idIndexOrder
@@ -752,12 +887,13 @@
 				return response;
 			};
 
-			extendAxis = function(type, axis, xResponse) {
-				if (!axis || (Ext.isArray(axis) && !axis.length)) {
+			getExtendedAxis = function(type, dimensionNames, xResponse) {
+				if (!dimensionNames || (Ext.isArray(dimensionNames) && !dimensionNames.length)) {
 					return;
 				}
 
-				var axis = Ext.clone(axis),
+				var dimensionNames = Ext.clone(dimensionNames),
+					mDimensions = [],
 					spanType = type === 'col' ? 'colSpan' : 'rowSpan',
 					nCols = 1,
 					aNumCols = [],
@@ -769,11 +905,17 @@
 					aAllObjects = [],
 					aUniqueIds;
 
+				for (var i = 0; i < dimensionNames.length; i++) {
+					mDimensions.push({
+						dimensionName: dimensionNames[i]
+					});
+				}
+
 				aUniqueIds = function() {
 					var a = [];
 
-					for (var i = 0, dim; i < axis.length; i++) {
-						dim = axis[i];
+					for (var i = 0, dim; i < mDimensions.length; i++) {
+						dim = mDimensions[i];
 
 						a.push(xResponse.nameHeaderMap[dim.dimensionName].items);
 					}
@@ -804,7 +946,7 @@
 							aSpan.push(nCols); //if just one item and top level, span all
 						}
 						else {
-							if (options.hideEmptyRows && type === 'row') {
+							if (layout.hideEmptyRows && type === 'row') {
 								aSpan.push(nCols / aAccNumCols[i]);
 							}
 							else {
@@ -870,7 +1012,7 @@
 
 					aColIds.push(id);
 				}
-	//aColIds	= [ aaaaaaaaBBBBBBBBccccccc, aaaaaaaaaccccccccccbbbbbbbbbb, ... ]
+	//aColIds	= [ abc, bcd, ... ]
 
 
 
@@ -925,7 +1067,7 @@
 
 				return {
 					type: type,
-					items: axis,
+					items: mDimensions,
 					xItems: {
 						unique: aUniqueIds,
 						gui: aGuiItems,
@@ -990,7 +1132,7 @@
 					totalColObjects = [],
 					htmlArray;
 
-				getTdHtml = function(options, config) {
+				getTdHtml = function(config) {
 					var cls,
 						colSpan,
 						rowSpan,
@@ -1008,20 +1150,20 @@
 					colSpan = config.colSpan ? 'colspan="' + config.colSpan + '"' : '';
 					rowSpan = config.rowSpan ? 'rowspan="' + config.rowSpan + '"' : '';
 					htmlValue = config.collapsed ? '&nbsp;' : config.htmlValue || config.value || '&nbsp;';
-					htmlValue = config.type !== 'dimension' ? pt.util.number.pp(htmlValue, options.digitGroupSeparator) : htmlValue;
-					displayDensity = pt.conf.pivot.displayDensity[config.displayDensity] || pt.conf.pivot.displayDensity[options.displayDensity];
-					fontSize = pt.conf.pivot.fontSize[config.fontSize] || pt.conf.pivot.fontSize[options.fontSize];
+					htmlValue = config.type !== 'dimension' ? pt.util.number.pp(htmlValue, layout.digitGroupSeparator) : htmlValue;
+					displayDensity = pt.conf.pivot.displayDensity[config.displayDensity] || pt.conf.pivot.displayDensity[layout.displayDensity];
+					fontSize = pt.conf.pivot.fontSize[config.fontSize] || pt.conf.pivot.fontSize[layout.fontSize];
 
 					return '<td class="' + cls + '" ' + colSpan + ' ' + rowSpan + ' style="padding:' + displayDensity + '; font-size:' + fontSize + ';">' + htmlValue + '</td>';
 				};
 
 				doSubTotals = function(xAxis) {
-					return !!options.showSubTotals && xAxis && xAxis.dims > 1;
+					return !!layout.showSubTotals && xAxis && xAxis.dims > 1;
 
 					//var multiItemDimension = 0,
 						//unique;
 
-					//if (!(options.showSubTotals && xAxis && xAxis.dims > 1)) {
+					//if (!(layout.showSubTotals && xAxis && xAxis.dims > 1)) {
 						//return false;
 					//}
 
@@ -1037,7 +1179,7 @@
 				};
 
 				doTotals = function() {
-					return !!options.showTotals;
+					return !!layout.showTotals;
 				};
 
 				getColAxisHtmlArray = function() {
@@ -1045,7 +1187,7 @@
 						getEmptyHtmlArray;
 
 					getEmptyHtmlArray = function() {
-						return (xColAxis && xRowAxis) ? getTdHtml(options, {cls: 'pivot-dim-empty', colSpan: xRowAxis.dims, rowSpan: xColAxis.dims}) : '';
+						return (xColAxis && xRowAxis) ? getTdHtml({cls: 'pivot-dim-empty', colSpan: xRowAxis.dims, rowSpan: xColAxis.dims}) : '';
 					};
 
 					if (!(xColAxis && Ext.isObject(xColAxis))) {
@@ -1063,7 +1205,7 @@
 
 						for (var j = 0, id; j < dimItems.length; j++) {
 							id = dimItems[j];
-							dimHtml.push(getTdHtml(options, {
+							dimHtml.push(getTdHtml({
 								type: 'dimension',
 								cls: 'pivot-dim',
 								colSpan: colSpan,
@@ -1071,7 +1213,7 @@
 							}));
 
 							if (doSubTotals(xColAxis) && i === 0) {
-								dimHtml.push(getTdHtml(options, {
+								dimHtml.push(getTdHtml({
 									type: 'dimensionSubtotal',
 									cls: 'pivot-dim-subtotal',
 									rowSpan: xColAxis.dims
@@ -1080,7 +1222,7 @@
 
 							if (doTotals()) {
 								if (i === 0 && j === (dimItems.length - 1)) {
-									dimHtml.push(getTdHtml(options, {
+									dimHtml.push(getTdHtml({
 										type: 'dimensionTotal',
 										cls: 'pivot-dim-total',
 										rowSpan: xColAxis.dims,
@@ -1199,7 +1341,7 @@
 
 					// Hide empty rows (dims/values/totals)
 					if (xColAxis && xRowAxis) {
-						if (options.hideEmptyRows) {
+						if (layout.hideEmptyRows) {
 							for (var i = 0, valueRow, empty, parent; i < valueObjects.length; i++) {
 								valueRow = valueObjects[i];
 								empty = [];
@@ -1402,7 +1544,7 @@
 						row = [];
 
 						for (var j = 0; j < mergedObjects[i].length; j++) {
-							row.push(getTdHtml(options, mergedObjects[i][j]));
+							row.push(getTdHtml(mergedObjects[i][j]));
 						}
 
 						a.push(row);
@@ -1469,7 +1611,7 @@
 
 						// Total col html items
 						for (var i = 0; i < xTotalColObjects.length; i++) {
-							a.push(getTdHtml(options, xTotalColObjects[i]));
+							a.push(getTdHtml(xTotalColObjects[i]));
 						}
 					}
 
@@ -1491,7 +1633,7 @@
 						}
 
 						if (xColAxis && xRowAxis) {
-							a.push(getTdHtml(options, {
+							a.push(getTdHtml({
 								type: 'valueGrandTotal',
 								cls: 'pivot-value-grandtotal',
 								htmlValue: Ext.Array.contains(empty, false) ? pt.util.number.roundIf(total, 1).toString() : '&nbsp;',
@@ -1512,7 +1654,7 @@
 
 					if (doTotals()) {
 						if (xRowAxis) {
-							dimTotalArray = [getTdHtml(options, {
+							dimTotalArray = [getTdHtml({
 								type: 'dimensionSubtotal',
 								cls: 'pivot-dim-total',
 								colSpan: xRowAxis.dims,
@@ -1551,15 +1693,19 @@
 					xColAxis,
 					xRowAxis;
 
-				xLayout = extendLayout(settings);
+				// Extended layout
+				xLayout = util.pivot.getExtendedLayout(layout);
 
+				// Param string
 				pt.paramString = getParamString(xLayout);
 				url = pt.init.contextPath + '/api/analytics.json' + pt.paramString;
 
+				// Validate request size
 				if (!validateUrl(url)) {
 					return;
 				}
 
+				// Show load mask
 				pt.util.mask.showMask(pt.viewport);
 
 				Ext.Ajax.request({
@@ -1578,13 +1724,14 @@
 					},
 					success: function(r) {
 						var html,
-							response = Ext.decode(r.responseText);
+							response = pt.api.response.Response(Ext.decode(r.responseText));
 
-						if (!validateResponse(response)) {
+						if (!response) {
 							pt.util.mask.hideMask();
 							return;
 						}
 
+						// Synchronize xLayout
 						xLayout = getSyncronizedXLayout(xLayout, response);
 
 						if (!xLayout) {
@@ -1592,13 +1739,17 @@
 							return;
 						}
 
-						xResponse = extendResponse(response, xLayout);
-
-						xColAxis = extendAxis('col', xLayout.col, xResponse);
-						xRowAxis = extendAxis('row', xLayout.row, xResponse);
-
+						// Extended response
+						xResponse = getExtendedResponse(response, xLayout);
+
+						// Extended axes
+						xColAxis = getExtendedAxis('col', xLayout.columnDimensionNames, xResponse);
+						xRowAxis = getExtendedAxis('row', xLayout.rowDimensionNames, xResponse);
+
+						// Create html
 						html = getTableHtml(xColAxis, xRowAxis, xResponse);
 
+						// Update viewport
 						pt.viewport.centerRegion.removeAll(true);
 						pt.viewport.centerRegion.update(html);
 
@@ -1609,8 +1760,11 @@
 							pt.viewport.downloadButton.enable();
 						}
 
+						pt.layout = layout;
 						pt.xLayout = xLayout;
 						pt.xResponse = xResponse;
+console.log("xResponse", xResponse);
+console.log("xLayout", xLayout);
 					}
 				});
 
@@ -1624,15 +1778,18 @@
 			}
 
 			Ext.Ajax.request({
-				url: pt.baseUrl + '/api/reportTables/' + id + '.json?links=false',
+				url: pt.baseUrl + '/api/reportTables/' + id + '.json?links=false&viewClass=dimensional',
 				method: 'GET',
 				failure: function(r) {
 					pt.util.mask.hideMask();
 					alert(r.responseText);
 				},
 				success: function(r) {
-					var response = Ext.decode(r.responseText);
-					pt.viewport.setFavorite(response);
+					var layout = pt.api.layout.Layout(Ext.decode(r.responseText));
+
+					if (layout) {
+						pt.viewport.setFavorite(layout);
+					}
 				}
 			});
 		}
@@ -1642,152 +1799,293 @@
 };
 
 PT.core.getAPI = function(pt) {
-	var api = {};
-
-	api.Layout = function(config) {
-		var col,
-			row,
-			filter,
-
-			removeEmptyDimensions,
-			getValidatedAxis,
-			validateLayout,
-
-			defaultOptions = {
-				showTotals: true,
-				showSubTotals: true,
-				hideEmptyRows: false,
-				displayDensity: 'normal',
-				fontSize: 'normal',
-				digitGroupSeparator: 'space',
-				reportingPeriod: false,
-				organisationUnit: false,
-				parentOrganisationUnit: false
-			};
-
-		removeEmptyDimensions = function(axis) {
-			if (!axis) {
-				return;
-			}
-
-			for (var i = 0, dimension, remove; i < axis.length; i++) {
-				remove = false;
-				dimension = axis[i];
-
-				if (dimension.dimensionName !== pt.conf.finals.dimension.category.dimensionName) {
-					if (!(Ext.isArray(dimension.items) && dimension.items.length)) {
-						remove = true;
-					}
-					else {
-						for (var j = 0; j < dimension.items.length; j++) {
-							if (!Ext.isString(dimension.items[j])) {
-								remove = true;
-							}
-						}
-					}
-				}
-
-				if (remove) {
-					axis = Ext.Array.erase(axis, i, 1);
-					i = i - 1;
-				}
-			}
-
-			return axis;
-		};
-
-		getValidatedAxis = function(axis) {
-			if (!(axis && Ext.isArray(axis) && axis.length)) {
-				return;
-			}
-
-			for (var i = 0, dimension; i < axis.length; i++) {
-				dimension = axis[i];
-
-				if (!(Ext.isObject(dimension) && Ext.isString(dimension.dimensionName))) {
-					return;
-				}
-			}
-
-			axis = removeEmptyDimensions(axis);
-
-			return axis.length ? axis : null;
-		};
-
-		getValidatedOptions = function(options) {
-			if (!(options && Ext.isObject(options))) {
-				return defaultOptions;
-			}
-
-			options.showTotals = Ext.isDefined(options.showTotals) ? options.showTotals : defaultOptions.showTotals;
-			options.showSubTotals = Ext.isDefined(options.showSubTotals) ? options.showSubTotals : defaultOptions.showSubTotals;
-			options.hideEmptyRows = Ext.isDefined(options.hideEmptyRows) ? options.hideEmptyRows : defaultOptions.hideEmptyRows;
-			options.displayDensity = options.displayDensity || defaultOptions.displayDensity;
-			options.fontSize = options.fontSize || defaultOptions.fontSize;
-			options.digitGroupSeparator = Ext.isDefined(options.digitGroupSeparator) ? options.digitGroupSeparator : defaultOptions.digitGroupSeparator;
-			options.reportingPeriod = Ext.isDefined(options.reportingPeriod) ? options.reportingPeriod : defaultOptions.reportingPeriod;
-			options.organisationUnit = Ext.isDefined(options.organisationUnit) ? options.organisationUnit : defaultOptions.organisationUnit;
-			options.parentOrganisationUnit = Ext.isDefined(options.parentOrganisationUnit) ? options.parentOrganisationUnit : defaultOptions.parentOrganisationUnit;
-
-			return options;
-		};
-
-		validateLayout = function() {
-			var a = [].concat(Ext.clone(col), Ext.clone(row), Ext.clone(filter)),
-				dimensionNames = [],
+	var dimConf = pt.conf.finals.dimension,
+		api = {
+			layout: {
+				Record: null,
+				Dimension: null,
+				Layout: null
+			},
+			response: {
+				Header: null,
+				Response: null
+			}
+		};
+
+	// Layout
+
+	api.layout.Record = function(config) {
+		var record = {};
+
+		// id: string
+
+		return function() {
+			if (!Ext.isObject(config)) {
+				console.log('Record config is not an object: ' + config);
+				return;
+			}
+
+			if (!Ext.isString(config.id)) {
+				alert('Record id is not text: ' + config);
+				return;
+			}
+
+			record.id = config.id;
+
+			if (Ext.isString(config.name)) {
+				record.name = config.name;
+			}
+
+			return Ext.clone(record);
+		}();
+	};
+
+	api.layout.Dimension = function(config) {
+		var dimension = {};
+
+		// dimension: string
+
+		// items: [Record]
+
+		return function() {
+			if (!Ext.isObject(config)) {
+				console.log('Dimension config is not an object: ' + config);
+				return;
+			}
+
+			if (!Ext.isString(config.dimension)) {
+				console.log('Dimension name is not text: ' + config);
+				return;
+			}
+
+			if (config.dimension !== pt.conf.finals.dimension.category.objectName) {
+				var records = [];
+
+				if (!Ext.isArray(config.items)) {
+					console.log('Dimension items is not an array: ' + config);
+					return;
+				}
+
+				for (var i = 0; i < config.items.length; i++) {
+					record = api.layout.Record(config.items[i]);
+
+					if (record) {
+						records.push(record);
+					}
+				}
+
+				config.items = records;
+
+				if (!config.items.length) {
+					console.log('Dimension has no valid items: ' + config);
+					return;
+				}
+			}
+
+			dimension.dimension = config.dimension;
+			dimension.items = config.items;
+
+			return Ext.clone(dimension);
+		}();
+	};
+
+	api.layout.Layout = function(config) {
+		var layout = {};
+
+		// columns: [Dimension]
+
+		// rows: [Dimension]
+
+		// filters: [Dimension]
+
+		// showTotals: boolean (true)
+
+		// showSubTotals: boolean (true)
+
+		// hideEmptyRows: boolean (false)
+
+		// displayDensity: string ('normal') - 'compact', 'normal', 'comfortable'
+
+		// fontSize: string ('normal') - 'small', 'normal', 'large'
+
+		// digitGroupSeparator: string ('space') - 'none', 'comma', 'space'
+
+		// userOrganisationUnit: boolean (false)
+
+		// userOrganisationUnitChildren: boolean (false)
+
+		// parentGraphMap: string ('')
+
+		// reportingPeriod: boolean (false) //report tables only
+
+		// organisationUnit: boolean (false) //report tables only
+
+		// parentOrganisationUnit: boolean (false) //report tables only
+
+		var getValidatedDimensionArray = function(dimensionArray) {
+			var dimensions = [];
+
+			if (!(dimensionArray && Ext.isArray(dimensionArray) && dimensionArray.length)) {
+				return;
+			}
+
+			for (var i = 0, dimension; i < dimensionArray.length; i++) {
+				dimension = api.layout.Dimension(dimensionArray[i]);
+
+				if (dimension) {
+					dimensions.push(dimension);
+				}
+			}
+
+			dimensionArray = dimensions;
+
+			return dimensionArray.length ? dimensionArray : null;
+		};
+
+		return function() {
+			var a = [],
+				objectNames = [],
 				dimConf = pt.conf.finals.dimension;
 
-			if (!(col || row)) {
+			config.columns = getValidatedDimensionArray(config.columns);
+			config.rows = getValidatedDimensionArray(config.rows);
+			config.filters = getValidatedDimensionArray(config.filters);
+
+			// Config must be an object
+			if (!(config && Ext.isObject(config))) {
+				alert(pt.el + ': Layout config is not an object');
+				return;
+			}
+
+			// At least one dimension specified as column or row
+			if (!(config.columns || config.rows)) {
 				alert(PT.i18n.at_least_one_dimension_must_be_specified_as_row_or_column);
 				return;
 			}
 
-			// Selected dimension names
+			// At least one period specified
+			a = [].concat(config.columns, config.rows, config.filters);
 			for (var i = 0; i < a.length; i++) {
 				if (a[i]) {
-					dimensionNames.push(a[i].dimensionName);
+					objectNames.push(a[i].dimension);
 				}
 			}
 
-			if (!Ext.Array.contains(dimensionNames, dimConf.period.dimensionName)) {
+			if (!Ext.Array.contains(objectNames, dimConf.period.objectName)) {
 				alert(PT.i18n.at_least_one_period_must_be_specified_as_column_row_or_filter);
 				return;
 			}
 
-			return true;
-		};
-
-		return function() {
-			var obj = {};
+			// Layout
+			layout.columns = config.columns;
+			layout.rows = config.rows;
+			layout.filters = config.filters;
+
+			// Properties
+			layout.showTotals = Ext.isBoolean(config.totals) ? config.totals : (Ext.isBoolean(config.showTotals) ? config.showTotals : true);
+			layout.showSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showSubTotals) ? config.showSubTotals : true);
+			layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : false;
+
+			layout.displayDensity = Ext.isString(config.displayDensity) &&  !Ext.isEmpty(config.displayDensity) ? config.displayDensity : 'normal';
+			layout.fontSize = Ext.isString(config.fontSize) &&  !Ext.isEmpty(config.fontSize) ? config.fontSize : 'normal';
+			layout.digitGroupSeparator = Ext.isString(config.digitGroupSeparator) &&  !Ext.isEmpty(config.digitGroupSeparator) ? config.digitGroupSeparator : 'space';
+
+			layout.userOrganisationUnit = Ext.isBoolean(config.userOrganisationUnit) ? config.userOrganisationUnit : false;
+			layout.userOrganisationUnitChildren = Ext.isBoolean(config.userOrganisationUnitChildren) ? config.userOrganisationUnitChildren : false;
+
+			layout.parentGraphMap = Ext.isString(config.parentGraphMap) ? config.parentGraphMap : '';
+
+			layout.reportingPeriod = Ext.isBoolean(config.reportingPeriod) ? config.reportingPeriod : false;
+			layout.organisationUnit = Ext.isBoolean(config.organisationUnit) ? config.organisationUnit : false;
+			layout.parentOrganisationUnit = Ext.isBoolean(config.parentOrganisationUnit) ? config.parentOrganisationUnit : false;
+
+
+			return Ext.clone(layout);
+		}();
+	};
+
+	// Response
+
+	api.response.Header = function(config) {
+		var header = {};
+
+		// name: string
+
+		// meta: boolean
+
+		return function() {
+			if (!Ext.isObject(config)) {
+				console.log('Header is not an object: ' + config);
+				return;
+			}
+
+			if (!Ext.isString(config.name)) {
+				console.log('Header name is not text: ' + config);
+				return;
+			}
+
+			if (!Ext.isBoolean(config.meta)) {
+				console.log('Header meta is not boolean: ' + config);
+				return;
+			}
+
+			header.name = config.name;
+			header.meta = config.meta;
+
+			return Ext.clone(header);
+		}();
+	};
+
+	api.response.Response = function(config) {
+		var response = {};
+
+		// headers: [Header]
+
+		return function() {
+			var headers = [];
 
 			if (!(config && Ext.isObject(config))) {
-				console.log('Layout config is not an object');
-				return;
-			}
-
-			col = getValidatedAxis(config.col);
-			row = getValidatedAxis(config.row);
-			filter = getValidatedAxis(config.filter);
-
-			if (!validateLayout()) {
-				return;
-			}
-
-			if (col) {
-				obj.col = col;
-			}
-			if (row) {
-				obj.row = row;
-			}
-			if (filter) {
-				obj.filter = filter;
-			}
-
-			obj.objects = config.objects;
-
-			obj.options = getValidatedOptions(config.options);
-
-			return obj;
+				alert('Data response invalid');
+				return false;
+			}
+
+			if (!(config.headers && Ext.isArray(config.headers))) {
+				alert('Data response invalid');
+				return false;
+			}
+
+			for (var i = 0, header; i < config.headers.length; i++) {
+				header = api.response.Header(config.headers[i]);
+
+				if (header) {
+					headers.push(header);
+				}
+			}
+
+			config.headers = headers;
+
+			if (!config.headers.length) {
+				alert('No valid response headers');
+				return;
+			}
+
+			if (!(Ext.isArray(config.rows) && config.rows.length > 0)) {
+				alert('No values found');
+				return false;
+			}
+
+			if (config.headers.length !== config.rows[0].length) {
+				alert('Data invalid');
+				return false;
+			}
+
+			response.headers = config.headers;
+			response.metaData = config.metaData;
+			response.width = config.width;
+			response.height = config.height;
+			response.rows = config.rows;
+
+			return response;
 		}();
 	};
 

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css	2013-04-22 13:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/styles/style.css	2013-05-15 09:45:38 +0000
@@ -234,8 +234,7 @@
 .pt-panel-title-data,
 .pt-panel-title-period,
 .pt-panel-title-organisationunit,
-.pt-panel-title-organisationunitgroupset,
-.pt-panel-title-dataelementgroupset {
+.pt-panel-title-dimension {
 	height: 17px;
 	background-repeat: no-repeat;
 	padding-left: 20px
@@ -250,10 +249,7 @@
 .pt-panel-title-organisationunit {
 	background-image: url(../images/organisationunit.png);
 }
-.pt-panel-title-organisationunitgroupset {
-	background-image: url(../images/organisationunitgroupset.png);
-}
-.pt-panel-title-dataelementgroupset {
+.pt-panel-title-dimension {
 	background-image: url(../images/dataelementgroupset.png);
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm	2013-04-15 20:44:56 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/jsonInitialize.vm	2013-05-15 09:45:38 +0000
@@ -4,8 +4,5 @@
 "ou":{"id":"$currentUser.getOrganisationUnit().uid","name":"$currentUser.getOrganisationUnit().name"},
 "ouc":[#foreach($ou in $currentUser.getOrganisationUnit().getSortedChildren()){"id":"$ou.uid","name":"$ou.name"}#if($velocityCount < $oucSize),#end#end]},
 "rootNodes":[#foreach($node in $rootNodes){"id": "$!{node.uid}","text": "$!encoder.jsonEncode( ${node.name} )","level": 1,"hasChildrenWithCoordinates": $!{node.hasChildrenWithCoordinates()},"expanded": true}#if($velocityCount<$rootNodes.size()),#end#end],
-"ougs":[#foreach($ougs in $organisationUnitGroupSets){"id":"$!{ougs.uid}","name":"$!encoder.jsonEncode($!{ougs.name})","items":[#foreach($oug in $ougs.getSortedGroups()){"id":"$!{oug.uid}","name":"$!encoder.jsonEncode($!{oug.name})"}#if($velocityCount<$ougs.getSortedGroups().size()),#end#end]}#if($velocityCount<$organisationUnitGroupSets.size()),#end#end],
-"degs":[#foreach($degs in $dataElementGroupSets){"id":"$!{degs.uid}","name":"$!encoder.jsonEncode($!{degs.name})","items":[#foreach($deg in $degs.getSortedGroups()){"id":"$!{deg.uid}","name":"$!encoder.jsonEncode($!{deg.name})"}#if($velocityCount<$degs.getSortedGroups().size()),#end#end]}#if($velocityCount<$dataElementGroupSets.size()),#end#end],
-"legendSets":[#foreach($set in $legendSets){"id":"$!{set.uid}","name":"$!encoder.jsonEncode($!{set.name})","legends":[#foreach($legend in $set.getMapLegends()){"id":"$!{legend.uid}","name":"$!encoder.jsonEncode($!{legend.name})","startValue":"$!{legend.startValue}","endValue":"$!{legend.endValue}","color":"$!encoder.jsonEncode($!{legend.color})","image":"$!encoder.jsonEncode($!{legend.image})"}#if($velocityCount<$set.getMapLegends().size()),#end#end]}#if($velocityCount<$legendSets.size()),#end#end]							
-}
-															
\ No newline at end of file
+"dimensions":[#foreach($dim in $dimensions){"id":"$!{dim.uid}","name":"$!encoder.jsonEncode($!{dim.name})"}#if($velocityCount<$dimensions.size()),#end#end]							
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-05-14 10:58:38 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-05-22 14:06:23 +0000
@@ -27,12 +27,9 @@
 			init.rootNodes[i].path = '/' + dv.conf.finals.root.id + '/' + init.rootNodes[i].id;
 		}
 
-		// Dynamic dimensions
-
-			// Sort by name
+		// Sort and extend dynamic dimensions
 		init.dimensions = dv.util.array.sortObjectsByString(init.dimensions);
 
-			// Extend
 		for (var i = 0, dim; i < init.dimensions.length; i++) {
 			dim = init.dimensions[i];
 			dim.dimensionName = dim.id;
@@ -40,6 +37,7 @@
 			dv.conf.finals.dimension.objectNameMap[dim.id] = dim;
 		}
 
+		// Viewport afterrender
 		init.afterRender = function() {
 
 			// Resize event handler
@@ -128,17 +126,11 @@
 			config.filters = [];
 
 			getDimension = function(config) {
-				if (dv.api.objectNameDimensionClassMap[config.objectName]) {
-					return dv.api.objectNameDimensionClassMap[config.objectName]({
-						dimension: config.objectName,
-						items: config.items
-					});
+				if (dv.api.objectNameDimensionClassMap[config.dimension]) {
+					return dv.api.objectNameDimensionClassMap[config.dimension](config);
 				}
 				else {
-					return dv.api.Dimension({
-						dimension: config.dimension,
-						items: config.items
-					});
+					return dv.api.Dimension(config);
 				}
 			};
 
@@ -4117,7 +4109,9 @@
 					dimConf = dv.conf.finals.dimension,
 					objectName,
 					periodRecords,
-					fixedPeriodRecords = [];
+					fixedPeriodRecords = [],
+					isOu = false,
+					isOuc = false;
 
 				// Type
 				dv.viewport.chartType.setChartType(xLayout.type);
@@ -4136,6 +4130,7 @@
 				objectName = dimConf.indicator.objectName;
 				if (dimMap[objectName]) {
 					dv.store.indicatorSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.indicatorAvailable}, {store: pt.store.indicatorSelected});
 				}
 
 				// Data elements
@@ -4143,6 +4138,7 @@
 				objectName = dimConf.dataElement.objectName;
 				if (dimMap[objectName]) {
 					dv.store.dataElementSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.dataElementAvailable}, {store: pt.store.dataElementSelected});
 					dv.viewport.dataElementDetailLevel.setValue(objectName);
 				}
 
@@ -4150,6 +4146,7 @@
 				objectName = dimConf.operand.objectName;
 				if (dimMap[objectName]) {
 					dv.store.dataElementSelected.add(Ext.clone(recMap[objectName]));
+					pt.util.multiselect.filterAvailable({store: pt.store.dataSetAvailable}, {store: pt.store.dataSetSelected});
 					dv.viewport.dataElementDetailLevel.setValue(objectName);
 				}
 
@@ -4175,6 +4172,7 @@
 					}
 				}
 				dv.store.fixedPeriodSelected.add(fixedPeriodRecords);
+				pt.util.multiselect.filterAvailable({store: pt.store.fixedPeriodAvailable}, {store: pt.store.fixedPeriodSelected});
 
 				// Group sets
 				for (var key in dimensionIdSelectedStoreMap) {
@@ -4199,9 +4197,6 @@
 
 				// Organisation units
 				if (recMap[dimConf.organisationUnit.objectName]) {
-					var isOu = false,
-						isOuc = false;
-
 					for (var i = 0, ouRecords = recMap[dimConf.organisationUnit.objectName]; i < ouRecords.length; i++) {
 						if (ouRecords[i].id === 'USER_ORGUNIT') {
 							isOu = true;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-05-14 10:30:34 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-05-15 13:00:34 +0000
@@ -2113,7 +2113,7 @@
 			}
 
 			if (!Ext.isBoolean(config.showTrendLine)) {
-				delete config.showTrendLine;
+				config.showTrendLine = layout.showTrendLine;
 			}
 			if (!Ext.isNumber(config.targetLineValue)) {
 				delete config.targetLineValue;
@@ -2128,13 +2128,13 @@
 				delete config.baseLineTitle;
 			}
 			if (!Ext.isBoolean(config.showValues)) {
-				delete config.showValues;
+				config.showValues = layout.showValues;
 			}
 			if (!Ext.isBoolean(config.hideLegend)) {
-				delete config.hideLegend;
+				config.hideLegend = layout.hideLegend;
 			}
 			if (!Ext.isBoolean(config.hideTitle)) {
-				delete config.hideTitle;
+				config.hideTitle = layout.hideTitle;
 			}
 			if (!Ext.isString(config.title) || Ext.isEmpty(config.title)) {
 				delete config.title;
@@ -2146,10 +2146,10 @@
 				delete config.rangeAxisTitle;
 			}
 			if (!Ext.isBoolean(config.userOrganisationUnit)) {
-				delete config.userOrganisationUnit;
+				config.userOrganisationUnit = layout.userOrganisationUnit;
 			}
 			if (!Ext.isBoolean(config.userOrganisationUnitChildren)) {
-				delete config.userOrganisationUnitChildren;
+				config.userOrganisationUnitChildren = layout.userOrganisationUnitChildren;
 			}
 
 			return true;