I am facing the following issues in generating a Pivot grid. 1. Sorting is enabled and it works fine in few cases. It doesn't work for the column headers "Components,Clothing,Bikes.."I have specified the following attributes, but still the sorting doesn't work on the mentioned columns. allowSorting: true, allowHeaderRowsSorting: true, allowHeaderColumnsSorting: true, firstSortDirection: "ascending", firstLevelSortDirection: "ascending", 2. How to do the number format for the specified columns "Components,Clothing,Bikes.."I am not sure how to apply the formating for these columns.
I have attached the code for your reference
Hello,
I'm attaching an updated sample in which I changed the aggregator function for "UnitsSold" measure with the default $.ig.OlapUtilities.prototype.sumAggregator('UnitsSold'). This fixed the Sorting and formatting issue. I also fixed the JavaScript error that was thrown initially due to a not escaped ".
Best regards,Martin PavlovInfragistics, Inc.
Thanks for your response. 1. Can you please provide me a solution for how to enable the sorting for the specified columns i.e. any workarounds? We need to enable sorting for all the columns/rows in the pivot grid as per our business requirement.2. Regarding formating, I tried applying your code but it doesn't seems to work. Not sure what is the mistake I am doing, I have attached the code for your reference, please clarify
If you want sorting feature for the igPivotGrid the custom aggregator is not the way to go. You should use the formatting function of the igGrid like this:
$("#pivotGrid").on("iggridrowsrendering", function (evt, ui) { // return if the column collection is not generated yet if (ui.owner.options.columns && ui.owner.options.columns.length === 0) { return; } for (var i = 0; i < ui.owner.options.columns.length; i++) { if (ui.owner.dataSource.data()[0] && $.isNumeric(ui.owner.dataSource.data()[0][ui.owner.options.columns[i].key])) { ui.owner.options.columns[i].formatter = function (val, rec) { if(val > 1000) return "<kbd style="background-color: green;">" + $.ig.formatter(parseFloat(val), "number", "numeric") + "</kbd>"; else return "<kbd style="background-color: red; color: white;">" + $.ig.formatter(parseFloat(val), "number", "numeric") + "</kbd>"; }; } } });
The code above binds to the igGrid.rowsRendering event and attaches a formatter function for all the columns that are numeric. Inside the formatter function a styling and formatting is done for the cell value.
Note: You should put this code before initializing the igPivotGrid.