Problem with Custom Number Format in Grd

Hi, I have a problem in my Grid with format in cell in my Grid.

I want to get format like this: 0,00 and 1150,00 and 550,55.

But.. my grid doesn't display 0.00 values and format another's columns is incorrect for me.

In database this value is in decimal format.

I attach screenview.

I was trying this way but it doesn't work:

<script>
    function dataBound() {
        for (var i = 0; i < this.columns.length; i++) {
            this.columns[5].format = "00,00";
        }
        this.refreshColumns();
    }
</script>


P.S This grid is in EDIT view. (it is in EditMode.Normal)



Attachment: amountttScreen_81f36dba.7z

1 Reply

DR Dhivya Rajendran Syncfusion Team February 19, 2020 12:54 PM UTC

Hi Bart , 

Greetings from Syncfusion support 

Query : Problem with custom number format in Grid. 

By default, formatting will be working based on the culture so we suggest you to use “QueryCellInfo” event to achieve the requirement. This event will triggered for each cell append to grid. In that event, customize the value based on your requirement. 

Please refer to the code snippet and sample for more reference. 

Index.cshtml 

@Html.EJS().Grid("InlineEdit").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col => 
… 
}).AllowPaging().QueryCellInfo("QueryCellInfo").PageSettings(page => page.PageCount(2)). Render() 

<script> 
    function QueryCellInfo(args){ 
        if (args.column.field == "Freight") { 
            var value = args.cell.innerText.toString().replace(',', '');      // will change the currency value 
            args.cell.innerText = value; 
            var data = args.cell.innerText.toString().replace('.', ',');      // will change the decimal point 
            args.cell.innerText = data; 
        } 
        if (args.cell.innerText === "") {                                                     // this will assign value to empty cell 
            args.cell.innerText = "0,00"; 
        }       
    } 
</script> 



Please get back to us if you need further assistance 

Regards 
R.Dhivya 


Loader.
Up arrow icon