Hi experts, I'd like to add some column format by intercepting iggridrowsrendering event using following code. As you can see I'd like to set format only for columns whose column header is '$ Index'. If I have only '$ Index' as a single measurement, it works fine. But if I drag the brand dimension to column, this approach does not work. You can see from the image, '$ Index' measurement become the top level column header, then the brand dimension second level column header, then my data. My code can only detect the direct column header of data, is there a way I can detect 122.9% actually belongs to '$ index' measurement???
$("#pivotGrid").on("iggridrowsrendering", function (evt, ui) { if (ui.owner.options.columns.length > 0) { for (var i = 0; i < ui.owner.options.columns.length; i++) { if (ui.owner.options.columns[i].headerText == "$ Index") { ui.owner.options.columns[i].formatter = function (val, row) { if (val === undefined) return ""; else { return "<span data-dollarIndex='" + val + "' class='dollarIndex'>" + val + "</span>"; } }; } } } });
oh...yes, you saved my life.
Hello Sathya,
Try setting styling in the aggregator function as well. Here is an example:
measures: [
{ caption: "Units Sold", name: "UnitsSold", aggregator: function (items, cellMetadata) {
var sum = 0;
$.each(items, function (index, item) {
sum += item.UnitsSold;
});
return "$ <span style='background-color:red'>" + sum + "</span>";
} }
]
Or if you need the measure info for some later point in time just add some class to the value:
return "$ <span data-measure='UnitsSold'>" + sum + "</span>";
Best regards,Martin PavlovInfragistics, Inc.
Hi Martin, Thank you for your reply. You are right, The aggregator function of measure is the right place to pinpoint the cell and get/set it's value. But how can I reference these cells later, I'd like to make it red/green based on their values? Thanks in advance.
You don't have context information for the cell measure in the column formatter so you cannot achieve your goal with this code.
What you can try is to define your customer aggregator function for the '$ Index' measure as described in the "Defining Metadata (igOlapFlatDataSource)" help topic in case you have igOlapFlatDataSource.
Here is an example code:
return "$ " + sum;
I'm not sure how it should be done for igXmlaDataSource. You can try setting FormatString property of the measure in your BI project.