I have a Discount__c
custom field with data type Percent(15, 3)
and it has a values of 1.219%
I am trying to fetch and display the value 1.219%
in standard datatable under "DISCOUNT
" column.
{ label: 'DISCOUNT', fieldName: 'Discount__c', type: 'percent', cellAttributes: {alignment: 'center'}}
But my datatable playground displaying column value as 122%
instead of 1.219%
, which is multiplying the value with 100
and rounding the value.
If i give type: 'number'
in JS
my datatable playground is displaying correct value like 1.219
but i want to display the %
symbol for each value in the "DISCOUNT
" column along with 3
decimals like 1.219%
.
Playground link :- https://developer.salesforce.com/docs/component-library/tools/playground/iBfK8QPn5/2/edit
HTML
<template>
<lightning-datatable
data={data}
columns={columns}
key-field="id">
</lightning-datatable>
</template>
JS Code
import { LightningElement } from 'lwc';
const columns = [
{label: 'Opportunity name', fieldName: 'opportunityName', type: 'text'},
{label: 'DISCOUNT', fieldName: 'discount__c', type: 'percent',
cellAttributes:{ alignment: 'center'}},
{label: 'Amount', fieldName: 'amount', type: 'currency',
cellAttributes:{ alignment: 'center'}, typeAttributes: { currencyCode: 'EUR',
alignment: 'center'}},];
const data = [{
id: 'a',
opportunityName: 'Cloudhub',
discount__c: 1.219,
amount: 25000
},
{
id: 'b',
opportunityName: 'Quip',
discount__c: 1.219,
amount: 740000
}];
export default class DatatableExample extends LightningElement {
data = data;
columns = columns;
}
He is the sample playground code link playground
Any suggestions please...