Flexsheet cell formatting to percentage

Posted by: kuhnimanagam_raznin on 2 November 2018, 9:27 am EST

    • Post Options:
    • Link

    Posted 2 November 2018, 9:27 am EST

    Hi,

    I was trying to set a particular column to Percentage format with 3 decimal places.This is the setting I used

    column:

    [ { binding: ‘col1’, header: ‘col1’, format: ‘p3’, dataType: ‘Number’ },]

    But it looks like though the format for display changed to 3 decimal places, the data that is been stored is what the user has typed.For Ex :When I type in 20.44444 it formats to 20.444 in the UI but the datasource keeps the original value as 20.44444.Is there any column configuration change to be made to keep the formatted value in the datasource as well.

    Thanks,

    Raznin

  • Posted 6 November 2018, 12:13 am EST

    Hi,

    Cell-formats are used only to format the display value.

    If you would like to modify the source value as well then you may handle the cellEditEnded event and perform the required changes.

    Please refer to the following code snippet:

    flexSheet.cellEditEnded.addHandler((s,e)=>{
      if(s.selectedSheetIndex == 0 && e.panel.cellType == wijmo.grid.CellType.Cell && s.columns[e.col].binding == 'percentage'){
        let data = e.panel.getCellData(e.row, e.col, true);
        e.panel.setCellData(e.row, e.col, data, true, true);
      }
    });
    

    You may also refer to the following sample: https://stackblitz.com/edit/js-auf1gp?file=index.js

    Regards

    Sharad

Need extra support?

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

Learn More

Forum Channels