Wijmo FlexGrid: Format with data type is decimal

Posted by: ntd119 on 10 November 2019, 2:28 pm EST

  • Posted 10 November 2019, 2:28 pm EST

    I have [COL_20] column, data type is decimal(10,4)
    On Wijmo FlexGrid, I set format bank
    However, It is formatted as an attachment
    I want it is not formated
    Please help me.
  • Replied 10 November 2019, 2:56 pm EST

    I attach the file
  • Replied 10 November 2019, 3:48 pm EST

    Hi,

    By default, the FlexGrid's column uses the 'n2' formatting which shows the decimal up to 2 digits. If you wish to show 4 decimal places, you will need to set the format of the column to 'n4'. Please refer to the sample below for reference:

    https://stackblitz.com/edit/js-faqyvv

    Regards,
    Ashwin
  • Replied 10 November 2019, 7:19 pm EST

    Thanks your answer.
    However, I have another question.
    For example: I have the following data
    data = [68.81, 85845.706, 71.1478, 465420.75409, ...]
    I want the result on the layout to be the same as the attached file, not format but it is number.
    Please help me.
  • Replied 12 November 2019, 5:21 pm EST

    Hi,

    We are sorry but this is not possible because the FlexGrid columns' data is formatted according to the format applied on that column.

    However, you can use the formatItem event of the FlexGrid to show the values as they are provided. Please refer to the sample link for demonstration:

    https://stackblitz.com/edit/js-xkta1q

    ~regards
  • Replied 6 May 2022, 2:30 am EST

    Hello,

    I'm also looking to add some decimal precision to our flexgrid. I'm wondering, what decimal formats does flexgrid support? I see here in this post we have 'n2' and 'n4', we're looking to add precision of up to 8 decimal places. Is this possible? Would it be as simple as just formatting it as something like n1 through n8?
  • Replied 8 May 2022, 7:35 pm EST

    Hello,

    Yes, to set the formatting up to 8 decimal places you can set the formatting to n8 on the columns. You can refer to the following links below for more formatting options and information:

    Formatting Demo link: https://www.grapecity.com/wijmo/demos/Core/Globalization/Formatting/purejs

    API link: https://www.grapecity.com/wijmo/api/classes/wijmo.globalize.html

    Regards
  • Replied 27 May 2022, 6:31 am EST

    Hello, I'm working on adding precision to my flex grid now, but it doesn't seem to be working and I'm not sure why. Here's the code that should be adding formatting to our grid:

     if (info.fields[i].dataType === 1)
    {
    formatString = "n" + info.fields[i].decimalPlaces.toString();
    }
    else
    {
    formatString = null;
    }
    this.flex.columns.push(new Column({
    binding: 'data.' + info.fields[i].bindingKey,
    header: info.fields[i].displayName,
    width: '*',
    minWidth: i === 0 ? 175 : 125,
    format: formatString
    }));

    I haven't been able to figure out why the new formatting isn't displaying. I would expect even for something like 1.23, if we changed the formatting to have 10 decimal places, it should be showing 1.2300000000 in the table. Is there any reason why this might be happening?
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels