Activity Forums Salesforce® Discussions Show space seprated number in Lightning datatable salesforce

  • Show space seprated number in Lightning datatable salesforce

    Posted by Balram on June 1, 2021 at 7:29 am

    Hi All,How to set table columns for following :-Having a requirement where need to show number in datatable by space btw them . For example :- 10000 should be like 10 000or 999999 should be like 999 999.Basically , I want space between thousand. How to setup the columns for dataTable for this ??Thanks B

    • This discussion was modified 3 years, 5 months ago by  Balram Kamboj.
    Prafull replied 3 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Prafull

    Member
    July 31, 2021 at 12:28 pm

    Hi Balram,

    You can take reference from below code.

    @track data;
    @track columns = columns;
    @api recordId;
    error;
    const columns = [
    {
    label: 'Number',
    fieldName: 'number',
    type: 'text',
    cellAttributes: { alignment: 'left' }
    }
    ];
    @wire(getData, {recordId:'$recordId' })
    wiredResult(result) {
    if (result.data) {
    var rows=result.data;
    for (var i = 0; i < rows.length; i++) {
    var row = rows[i];
    if (row.NumberValue.length>2) row.number= row.NumberValue.substring(0,2) +' '+row.NumberValue.substring(2,row.NumberValue.length);
    }
    this.data = rows;
    this.error = undefined;
    } else if (result.error) {
    this.error = result.error;
    this.data = undefined;
    }
    }

    • This reply was modified 3 years, 3 months ago by  Prafull.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos