Determining number of visible decimal places at runtime

Not Answered This post has 0 verified answers | 5 Replies | 2 Followers Thread's RSS feed.

QBSOLPHX
Points 1,516
Replied On: Mon, Apr 15 2013 8:20 PM Reply

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

  • Post Points: 20

All Replies

[Infragistics] Maria
Points 8,375
Infragistics Employee
Replied On: Fri, Apr 19 2013 10:45 AM Reply

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.

Sincerely,
Maria
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
QBSOLPHX
Points 1,516
Replied On: Fri, Apr 19 2013 11:20 AM Reply

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.

Thanks,

Steve

  • Post Points: 20
[Infragistics] Maria
Points 8,375
Infragistics Employee
Replied On: Wed, Apr 24 2013 10:14 AM Reply

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.

Sincerely,
Maria
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 5
[Infragistics] Maria
Points 8,375
Infragistics Employee
Replied On: Tue, Apr 30 2013 5:05 AM Reply

Hello Steve, 

I am just checking if you have any other questions regarding this issue.

Sincerely,
Maria
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
QBSOLPHX
Points 1,516
Replied On: Tue, Apr 30 2013 12:23 PM Reply

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

  • Post Points: 5
Page 1 of 1 (6 items) | RSS