I am trying to hide columns for the records which are having null or zero values in the row, for this I am using filter method achieve. But for some reason filter function is not calling.
Below is the data sample,
[
{
"cs": 1000,
"DateTime": "02/06/2015",
"subject": "lect",
"math": 1777.655,
"politics": 0.88
},
{
"cs": null,
"DateTime": "02/07/2015",
"subject": "lect",
"math": 344,
"politics": 0.99
},
{
"cs": null,
"DateTime": "02/08/2015",
"subject": "lect",
"math": 920.304,
"politics": 0.777
},
]
Here is the my custom aggregators function and pivotable configuration, where in filter is called.
pivotUI configuration
.pivotUI( {
rows: ["subject"],
cols: ["DateTime"],
aggregators: {
"math": successRate,
"politics": successRate2,
"cs":successRate3
},
hiddenAttributes: ['Date'],
})
Custom aggregator function
var successRate3 = function() {
return function() {
return {
sumSuccesses: "",
sumTrials: 0,
push: function(record) {
if (!isNaN(parseFloat(record['cs'])) && record['cs'] !== null) {
this.sumSuccesses = parseFloat(record['cs']);
}
},
value: function() { return this.sumSuccesses },
format: function(x) { return x; },
filter: function(record){ return record["cs"] > 0; },
rendererName: "TABLE",
numInputs: 0
};
};
};