We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Decimal handling of Columndecimal processing of column

안녕하세요 .

<e-treegrid-column field="MAX_ROOM_TEMP" disableHtmlEncode="false" headerText="MAX ROOM TMP.(T<sub>RM</sub>, ℃)" format="N5" visible="true" width="180" headerTextAlign="Center" defaultValue="@empty"></e-treegrid-column>

I designated "Format = N5" in the column to express up to the fifth decimal place when a number exists in the decimal point.


However, if a number does not exist in a decimal point, I want to express it as an integer.


Is there any way?



Example)

In the case of '24.66666666666666',

24.66666


In the case of '24', 24


Regards.


1 Reply

PS Pon Selva Jeganathan Syncfusion Team January 5, 2023 02:26 PM UTC

Hi TaeWook Kang,


Query: However, if a number does not exist in a decimal point, I want to express it as an integer.


We achieved your requirement by using the queryCellInfo event of the treegrid. This event allows you to customize the cells of the TreeGrid by providing a callback function that is executed for each cell.


Please refer to the below code snippet,


 <ejs-treegrid id="TreeGrid" dataSource="ViewBag.dataSource"......

                            queryCellInfo="queryCellInfo">

 

<e-treegrid-columns>

………..

                        <e-treegrid-column field="price" headerText="Price" format="n5"></e-treegrid-column>

                    </e-treegrid-columns>

                </ejs-treegrid>

 

…………

 

<script>

queryCellInfo(args) {

    if (args.column.field == 'price' && Number.isInteger(args.data.price)) {

      args.cell.innerText = args.data.price.toString();

    }

  }

</script>

 


Please refer to the below screenshot,



Please refer to the below API documentation

https://ej2.syncfusion.com/documentation/api/treegrid/#querycellinfo


Regards,

Pon selva


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly






Loader.
Live Chat Icon For mobile
Up arrow icon