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
close icon

Problem with leading decimal points in grid cell

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.

4 Replies

WR Will Rogers 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.


SM Saravanan M Syncfusion Team 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


WR Will Rogers 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.


SM Saravanan M Syncfusion Team December 30, 2013 12:15 PM UTC

Hi Will,

Thanks for your update.

Regards,

Saravanan.M


Loader.
Live Chat Icon For mobile
Up arrow icon