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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem with leading decimal points in grid cell

Thread ID:

Created:

Updated:

Platform:

Replies:

114766 Dec 6,2013 05:25 PM UTC Dec 30,2013 12:15 PM UTC WPF 4
loading
Tags: GridControl
Will Rogers
Asked On December 6, 2013 05:25 PM UTC

Syncfusion v10.204.0.75
.Net 4.0, WPF (desktop app) project on Win 8.1

I have a requirement to allow users to enter a leading decimal point into a GridDataControl cell that is bound (Mapped) to a double. For example, the user needs to be able to enter .5 and 0.5. I have the column set to update on property changes, forcing the data binding to happen with every keystroke, so other fields can update as the user types. For other reasons, I am generating the grid in code dynamically, but that shouldn't matter.

I can't find a combination of flags or column types that will allow this to happen. Using Reflector on Syncfusion's dlls, I can see where the cell eventually calls Double.TryParse() on the string, which fails because it initially just contains this: "." It appears Syncfusions code effectively ignores a leading decimal in a GridDataDoule

Here's what I currently have, and any help would be appreciated.

var column = new GridDataDouleEditVisibleColumn() // note this class is misspelled in my version.
{
HeaderText = "Header",
MappingName = allocColumnName,
Binding = allocBinding, // this binding just adds a value converter that never fires in the case of a leading zero
Width = new GridDataControlLength(54d),
ColumnStyle = new GridDataColumnStyle()
{
Font = new GridFontInfo() { FontWeight = FontWeights.Bold },
IsEditable = true,
MaxLength = 4,
DoubleEdit = new GridDoubleEditStyleInfo()
{
IsScrollingOnCircle = false
},
//CellType = "DoubleEdit",
//CellEditTemplate = new DataTemplate()
NumberFormat = new System.Globalization.NumberFormatInfo()
{
NumberDecimalDigits = 1
},
}
};

Thanks,
Will.

Will Rogers
Replied On December 6, 2013 05:39 PM UTC

Just to be clear on  my goal, I'd like to find some way for the grid to either ignore a leading decimal point (but leave it present in the cell), or somehow insert a zero in front of the decimal (e.g., "0.") so the parsing would succeed.

Worst case, I guess I can change what it's bound to to a string, but I think I'd have to change a lot of existing code.

Thanks,
Will.

Saravanan M [Syncfusion]
Replied On December 10, 2013 09:19 AM UTC

Hi Will,

 

Sorry about the delay caused,

 

We have analyzed you query and you can display 0 before the decimal value by setting the particular column type as decimal or double. By default these cell types shows the 0 before the decimal value. if you type .6 , it will display as 0.6. If this is not your requirement, please modify the attached sample based on your requirement and share the exact requirement with us?  It would be helpful for us to server you better.

 

Please let us know if you need further assistance.

 

Regards,

Saravanan.M



GridDataControlSample_39939bf2.zip

Will Rogers
Replied On December 18, 2013 03:52 PM UTC

Thanks for the reply. I ended up binding to a string property instead and am handling the parsing in the setter for that property. Not ideal but it works.

Saravanan M [Syncfusion]
Replied On December 30, 2013 12:15 PM UTC

Hi Will,

Thanks for your update.

Regards,

Saravanan.M


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;