Ag-Grid: Number Formatting eg:123456.78 to 123,457

后端 未结 3 1408
情歌与酒
情歌与酒 2021-02-13 09:40

I have huge sets of numeric data. this needs to be rendered as comma separated value. For Ex. 123456.78 to be rendered as 123,457 using Ag-Grid. Kindl

3条回答
  •  盖世英雄少女心
    2021-02-13 09:57

    You can do this by writing a "customcellRenderer", when you create a column definition provide a function to "cellRenderer " attribute and in renderer use number filter, something like this

    var colDef = {
        name: 'Col Name',
        field' 'Col Field',
        cellRenderer: function(params) {
            var eCell = document.createElement('span');
            var number;
            if (!param.value || !isFinite(param.value)) {
                number = '';
            } else {
                number = $filter('number')(param.value, 0);
            }
            eCell.innerHTML = number;
            return eCell;
        }
    }
    

提交回复
热议问题