Hello,
I am planning to provide the user the pivot configurator, so they can pivot any way they want.
I would like to be able to save/load those configurations to/from the database, how do we do that?
Thank you,
Hello,
I am planning to provide the user the pivot configurator, so they can pivot any way they want.
I would like to be able to save/load those configurations to/from the database, how do we do that?
Thank you,
You can get the pivot configuration from the plugin:
var cfg = pivot.getPlugin('configurator').getConfiguration();
Clone that object and from that you can get aggregate, topAxis, leftAxis objects, but you need to clean them up, delete some properties, functions, arrays, IDs, etc. you end up with the configuration properties.
You should also, grab and save the filters and sorters, and any pivot settings.
Then you can load a saved configuration using:
pivot.reconfigurePivot(cfg);
Then apply the filters and sorters, and any pivot settings like totals position, etc.
You can get the pivot configuration from the plugin:
var cfg = pivot.getPlugin('configurator').getConfiguration();
Clone that object and from that you can get aggregate, topAxis, leftAxis objects, but you need to clean them up, delete some properties, functions, arrays, IDs, etc. you end up with the configuration properties.
You should also, grab and save the filters and sorters, and any pivot settings.
Then you can load a saved configuration using:
pivot.reconfigurePivot(cfg);
Then apply the filters and sorters, and any pivot settings like totals position, etc.
varsos
I end up doing as follow to retrieve the config directly from the pivot(me):
Code:/** * This method retrieves the pivot view config. */ getPivotConfig: function () { var me = this, matrix = me.getMatrix(), matrixDimensionFields = 'id,header,dataIndex,sortIndex,width,flex,align,sortable,direction,caseSensitiveSort,filter,formatter,exportStyle,blankText,showZeroAsBlank,aggregator,grouper', matrixDimensionFilterFields = 'dimensionId,topType,topOrder,topSort,isTopFilter,type,operator,value,caseSensitive', getMatrixConfig = function (i) { var config = Ext.copy({}, i.initialConfig, matrixDimensionFields); if (config.filter) { config.filter = Ext.copy({}, config.filter, matrixDimensionFilterFields); } return config; }; return { leftAxis: Ext.Array.map(matrix.leftAxis.dimensions.items, getMatrixConfig), topAxis: Ext.Array.map(matrix.topAxis.dimensions.items, getMatrixConfig), aggregate: Ext.Array.map(matrix.aggregate.items, getMatrixConfig) }; }
The gist of it is to cleanup the configuration items (and filters). JSON.stringify should work fine with the resulting object.