I have a custom aggregator function that I'm using to enhance the numbers shown based on outside data (not part of the dataSource). The problem I'm having is the igPivotGrid caches the results of a given expansion level and won't call the aggregator function again if it thinks it already has the answer.
So basically, I'm trying to force the grid to recalculate all the visible cells. I've tried the following:
1) collapse/expandTupleMember for everything that is open/closed
2) $('#pivotView').igPivotView("pivotGrid").updateGrid() apparently does nothing because it does not see any changes. (Is there a way to set a "dirty" flag?)
In both cases, it just pulls the cached aggregate data instead of running the aggregate functions again.
Hello John,
In order to be able to investigate this specific scenario, I would need a working sample demonstrating the behavior in question, and particularly at what stage the custom aggregation is being applied. This would allow me to research any possible options for triggering the cell 'updates' in this case. The datasource updates not being detected in this scenario are the likely reason also for collapsing and expanding tuples not having the desired effect.
Please do not hesitate to contact me with any updates or questions.
The cube is setup the with the following option:
measures: [ { caption: "Units Sold", name: "UnitsSold", // returns a function that will be used as sum aggregatro on the 'UnitsSold property' of the data objects aggregator: qtyAggregator('UnitsSold') }]
where
var newData = []; var qtyAggregator = function(propertyName){ return function (items, cellMetadata) { var sum = 0; $.each(items, function (index, item) { sum += item[propertyName]; }); } for(var i=0;i<newdata.length;i++){ if(matchesCellMetafilter(newdata[i],cellMetadata)){ sum += newData[i][propertyName]; }
Basically, there are data changes happening after the data was initially loaded into the grid. I add them into the aggregate calculations (which works fine), however the grid caches the results of that aggregation calculation, which means when newData changes, I can't force it to recalculate the aggregation
Thank you for your reply and the snippet.
Am I understanding you correctly that the aggregator function is being called externally from the grid functionality at some point to reflect the new values (which are not committed in the datasource)? In order to be able to debug this I would need a working sample showing the full scenario.
Please feel free to contact me if you are still experiencing any issues with this matter.
It is still an issue - I just have not had a chance to write a sample app to demo it. It's not really a "demo" problem though. Take any sample pivot app at all setup with a aggregator function. Set a breakpoint on the aggregator function and you'll see it fired the first time you expand a dimension. Collapse that dimension back and then re-open it. The aggregator function will NOT fire this time because the grid is caching the results. I just need a way to have the grid NOT cache the results in that scenario (i.e. mark the DS as dirty, flush the cache, etc).
John
Hi John,
Thank you for your reply. I think I understand your requirement now. I have contacted our engineers and am discussing any possible approaches for achieving the desired calculation, and will keep you posted of any available information.
Please do not hesitate to contact me with any updates in the meantime.
Thank you for your patience.
Our engineers have created an example for you for forcing an update on the pivot grid's datasource. Essentially, the datasource is being "tricked" into a dirty state:
$("#button1").on("click", function() { var dateHierarchy = dataSource.getCoreElement( function(b){return b.uniqueName()== '[Date].[Dates]'}, $.ig.Hierarchy.prototype.$type); dataSource.addColumnItem(dateHierarchy); dataSource.removeColumnItem(dateHierarchy); dataItems[0].UnitsSold = 100000000; dataSource.update(); });
$("#button1").on("click", function()
{
var dateHierarchy = dataSource.getCoreElement(
function(b){return b.uniqueName()== '[Date].[Dates]'},
$.ig.Hierarchy.prototype.$type);
dataSource.addColumnItem(dateHierarchy);
dataSource.removeColumnItem(dateHierarchy);
dataItems[0].UnitsSold = 100000000;
dataSource.update();
});
A jsfiddle showing this can be found at:
jsfiddle.net/wow4zzsy/17/
Clicking the button next to the grid will force the data source to be refreshed (and the aggregators to be fired once again).
Hope this helps. Please feel free to contact me if you have any questions.
Please feel free to contact me if you have any further questions regarding this matter.