We have a need to provide different back colors for some cells, depending on user rules (i.e. variances). How can this be best accomplished with the OLAP Pivot Grid? Are there any examples available?
Thanks
Hello epsiwebdev,
Thank you for posting in our community.
What I can suggest for achieving your requirement is handling pivotGridRendered event. In this event the igGrid widget, which contains the data could be accessed using the ui.grid. Afterwards in the igGrid`s rendered event you could access any particular cell that you want to style and set its background color. This could be achieved as following:
$("#pivotGrid").igPivotGrid({ dataSource: dataSource, height: "650px", width: "670px", pivotGridRendered: function (evt, ui) { ////get reference to the grid var grid = ui.grid; var gridID = grid.id(); //handle rendered event of the igGrid $(document).delegate("#" + gridID, "iggridrendered", function (evt, ui) { var grid = ui.owner; var cell = grid.cellAt(0, 0); cell.style.backgroundColor = "red"; }); } });
$("#pivotGrid").igPivotGrid({
dataSource: dataSource,
height: "650px",
width: "670px",
pivotGridRendered: function (evt, ui) {
////get reference to the grid
var grid = ui.grid;
var gridID = grid.id();
//handle rendered event of the igGrid
$(document).delegate("#" + gridID, "iggridrendered", function (evt, ui) {
var grid = ui.owner;
var cell = grid.cellAt(0, 0);
cell.style.backgroundColor = "red";
});
}
Please note that the cell value could also be retrieved there and its style could be set based on whether or not the value meets a particular condition.
I also made a small sample illustrating my suggestion and I am attaching it for your reference.
Some further reference about igPivotGrid`s options, events and methods could be found at:
http://help.infragistics.com/jQuery/2014.1/ui.igPivotGrid
I hope you find this information helpful.
Please let me know if you need any further assistance with this matter.http://help.infragistics.com/jQuery/2014.1/ui.igPivotGrid
Please feel free to contact me if you have any additional questions regarding this matter.