Greetings
For a project involving charts & pivots i'm trying to see if igniteui is the toolkit we need.
However i'm having trouble with the folliwing:
In a pivot grid containing data, whenever an user clicks on e cell i need to now the column and row dimension. I've seen an example on the forum on which you can get the label of the row of column but i also need the level in the hierarchy.
Using a custom aggregator i found out you can acces cellmetadata but this doesn't seem to contain what i need.
var measure = { caption: n, name: n, aggregator: function (items, cellMetadata) { console.log(cellMetadata); return "<span data-rowdimension='" + rowmeasureheresomehow + "' data-rowdimensionlabel='"+ rowdimensionvalueheresomehow +"'>" + sumAggregator(items, cellMetadata) + "</span>"; } };
Thanks in advance
Hello Matthias,
Try with the following code:
{ caption: "Units Sold", name: "UnitsSold", aggregator: function (items, cellMetadata) { var sum = 0, rowmeasureheresomehow, rowdimensionvalueheresomehow; $.each(items, function (index, item) { sum += item.UnitsSold; }); rowmeasureheresomehow = cellMetadata.rowTuples()[cellMetadata.rowIndex()].members().item(0).uniqueName(); rowdimensionvalueheresomehow = cellMetadata.columnTuples()[cellMetadata.columnIndex()].members().item(0).uniqueName(); return "<span data-rowdimension='" + rowmeasureheresomehow + "' data-rowdimensionlabel='"+ rowdimensionvalueheresomehow +"'>" + sum + "</span>"; } },
{ caption: "Units Sold", name: "UnitsSold", aggregator: function (items, cellMetadata) {
var sum = 0, rowmeasureheresomehow, rowdimensionvalueheresomehow;
$.each(items, function (index, item) {
sum += item.UnitsSold;
});
rowmeasureheresomehow = cellMetadata.rowTuples()[cellMetadata.rowIndex()].members().item(0).uniqueName();
rowdimensionvalueheresomehow = cellMetadata.columnTuples()[cellMetadata.columnIndex()].members().item(0).uniqueName();
return "<span data-rowdimension='" + rowmeasureheresomehow + "' data-rowdimensionlabel='"+ rowdimensionvalueheresomehow +"'>" + sum + "</span>";
} },
I'm also attaching a working sample.
Best regards, Martin Pavlov Infragistics, Inc.
Hey
This seems to get me a long way. However.
What if there are multiple row/col dimensions and or multiple measures.
How can you get all of of them ?
Hello Mathias,
Try with this code:
{ caption: "Units Sold", name: "UnitsSold", aggregator: function (items, cellMetadata) { var sum = 0, rowmeasureheresomehow, rowdimensionvalueheresomehow; $.each(items, function (index, item) { sum += item.UnitsSold; }); rowmeasureheresomehow = cellMetadata.rowTuples()[cellMetadata.rowIndex()].members().a.map(function(i) {return i.uniqueName();}); rowdimensionvalueheresomehow = cellMetadata.columnTuples()[cellMetadata.columnIndex()].members().a.map(function(i) {return i.uniqueName();}); return "<span data-rowdimension='" + rowmeasureheresomehow + "' data-rowdimensionlabel='"+ rowdimensionvalueheresomehow +"'>" + sum + "</span>"; } },
rowmeasureheresomehow = cellMetadata.rowTuples()[cellMetadata.rowIndex()].members().a.map(function(i) {return i.uniqueName();});
rowdimensionvalueheresomehow = cellMetadata.columnTuples()[cellMetadata.columnIndex()].members().a.map(function(i) {return i.uniqueName();});
I'm attaching an updated sample for your reference.
Best regards,Martin PavlovInfragistics, Inc.
This seems to do the trick!
Thx a lot !
You're welcome.