As the subject states, we recently had issues where the grand total was summing .1 and .2 which caused the grand total to become over 10 characters in length and be truncated. Can decimal.js be implemented or how do prevent the JS issue in those columns totals?
|
dataSourceSettings: {
enableSorting: true,
columns: [{ name: 'Year' }, { name: 'Quarter' }],
values: [
{ name: 'Sold', caption: 'Units Sold' },
{ name: 'Amount', caption: 'Sold Amount', type: 'Avg' }
],
dataSource: getPivotData(),
rows: [{ name: 'Country' }, { name: 'Products' }],
// set format here
formatSettings: [{ name: 'Amount', format: 'N2' }],
expandAll: false,
filters: []
},
|
So this worked, but is there a way to do conditional formatting based on the column data? Specifically, I have some that should be integers, some are currency, some are float. I just have the following (Type will return with: Payments, Quantity, Percentage):
|
this.dataSourceSettings = {
dataSource: Pivot_Data,
expandAll: false,
enableSorting: true,
formatSettings: [{ name: 'Amount', format: 'C0' }, { name: 'In_Stock', format: 'P0' },
{ name: 'Sold', format: 'N0' }],
columns: [{ name: 'Year' }, { name: 'Order_Source', caption: 'Order Source' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
values: [{ name: 'In_Stock', caption: 'In Stock' },
{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }]
};
|
Thank you for the response, what I meant was if "In_Stock" === "Yes" then "Amount" === "C2" else "N0" or something like that. Is that possible?
|
aggregateCellInfo(args) {
if (args.fieldName === "Amount" && this.pivotObj.engineModule.formatFields[args.fieldName]) {
delete this.pivotObj.engineModule.formatFields[args.fieldName];
this.pivotObj.engineModule.formatFields[args.fieldName] = { name: args.fieldName, format: (args.value > 999999 ? 'C2' : 'N0') };
}
}
<ejs-pivotview #pivotview id='PivotView' [dataSourceSettings]=dataSourceSettings width='100%' height='290'
[gridSettings]='gridSettings' (aggregateCellInfo)="aggregateCellInfo($event)">
</ejs-pivotview>
|