Hello,
I have a XamDataGrid with several columns of type double. In our application, the user has the ability to set the number of decimal places for these columns at runtime. I need a way to examine these columns to determine how many decimal places are currently visible. Is there any easy way to do that?
Thanks,
Steve Wall
Hello Steve,
Thank you for posting!
I have been looking through the described scenario. In order to better understand your approach could you give me more details on how you set the number of decimal places that are available in the double columns? Do you set a mask property? This will help me provide you with a better solution. Thank you.
Hi Maria,
When users decide to change the number of decimal places for numeric columns, we typically set a mask on the field similar to something like "{double:-5.6}". It's a fairly dynamic situation. We have other functionality where I'm performing some secondary calculations and need to round the numeric results, but I need to round to the same level of precision they've selected to view the data in the grid. So I need some way of determining the number of visible decimal places on the XamDataGrid field for the secondary rounding.
I hope this makes more sense.
Steve
Hi Steve,
Thank you for the provided details. I have been looking into this and it seems that there is no build-in functionality for checking how many digits could be set in a cell. What I could suggest you here is using the Text property of the XamNumericEditor which is used to display the decimal values in the cells. Then you could separate the string to a char array and use its Length property to determine how many digits are displayed.
Please do not hesitate to ask if you have any questions.
I am just checking if you have any other questions regarding this issue.
Thanks, Maria.
I guess this approach is ok. It’s not great because you’d need to know the decimal separator, and of course that depends on the locale. I’ll probably use a similar approach and try to come up with something for the separator.
Thanks, Steve