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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PositiveInfinity and NegativeInfinity as strings in DoubleTextBox

Thread ID:

Created:

Updated:

Platform:

Replies:

121536 Dec 27,2015 08:24 PM UTC Dec 31,2015 01:05 PM UTC WPF 5
loading
Tags: SfDataGrid
Carlos Fernando Consigli
Asked On December 27, 2015 08:24 PM UTC

Hello. 

I'm using a GridNumericColumn which according to the online documentation uses a DoubleTextBox as value editor.
Is there a way to enter the double value PositiveInfinity (System.Double.PositiveInfinity) or NegativeInfinity (System.Double.NegativeInfinity) as a string in this field?
When populating the grid, the infinity values from database are shown in the grid as "79228162514264300000000000000.00". When the grid is scanned in backend, these values are read as infinity (System.Double.IsPositiveInfinity is true). However, if I enter edit mode and commit changes without actually modifying the value, in the cell these cells are no longer "infinity" when I test them in backend with System.Double.IsPositiveInfinity but instead, the same entered number which is 7.92281625142643E+28 is read.
Is there a way to allow entering the strings "Infinity" and "-Infinity" in the field? Maybe the solution is to just use a GridTextColumn in combination with an IValueConverter, but I'm just asking in case DoubleTextBox was already taking this in account with some option I'm missing.

Thanks in advance!

Fernando

Ayyanar Sasi Kumar Jeyaraj [Syncfusion]
Replied On December 28, 2015 02:15 PM UTC

Hi Fernando,

When you are binding maximum infinity value, the value is not displayed in view and its correctly displayed in edit mode. Is this the issue you are referring? Refer the below sample where we tried to reproduced this issue.

Sample: http://www.syncfusion.com/downloads/support/forum/121536/ze/Numeric_textbox_in_wpf1708064484

Could please confirm the issue to provide the fix?

Regards
Ayyanar

Carlos Fernando Consigli
Replied On December 28, 2015 04:28 PM UTC

Hi Ayyanar. Thanks for your quick answer.
I was referring to both the inability to enter (and read) the value (-/+)Infinity in the field as "Infinity" instead as a number, and the fact that if you only enter edit mode and commit changes, the value is no longer read as Infinity in the model.

Everything reduces to the fact that there is no way to enter the value Infinity in the fields that don't have Infinity as an initial value.  You can enter the number 79228162514264300000000000000.00 which is the one shown for initial "Infinities", and it will persist it in the model as 7.92281625142643E+28. In fact, in my opinion this last behaviour is correct because Infinity should be just "Infinity" and not be mapped to any natural number, and it is ok to persist 79228162514264300000000000000.00 as a number. I think the solution may be to show the string "Infinity" for infinity values, and to allow the user to enter the word "Infinity" (or -Infinity) in the field.
Of course, I understand that this may be a sort of a hard and breaking change, because of the "masked" nature of this control and because as it currently only takes numbers and decimal separators as inputs, it should necessarily start accepting characters to allow "Infinity" with all what that implies (validating for invalid strings, etc).

Fernando

Sivakumar R [Syncfusion]
Replied On December 29, 2015 03:31 PM UTC

Hi Fernando,

We have analyzed and your requirement to display infinity in GridNumericColumn can’t be achieved. But you can use GridTextColumn to display as you required. You can validate the editing by CurrentCellValidating event.

this.datagrid.CurrentCellValidating += Datagrid_CurrentCellValidating;

private void Datagrid_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args)

{

    if (args.Column.MappingName != "salary")

        return;


    double d;

    if(args.NewValue == null || !double.TryParse(args.NewValue.ToString(), out d))

    {

        args.ErrorMessage = "Enter valid double value";

        args.IsValid = false;

    }
}


Sample:
http://www.syncfusion.com/downloads/support/forum/121536/ze/Sample217465157



Please let us know if you have any questions.

Thanks,
Sivakumar

Carlos Fernando Consigli
Replied On December 30, 2015 04:26 PM UTC

Perfect, thanks, I implemented that solution and it's working ok. Also, that way was not necessary to deal with the IValueConverter.
Thanks, I really appreciate you took time to help me.
Greetings,

Fernando

Ayyanar Sasi Kumar Jeyaraj [Syncfusion]
Replied On December 31, 2015 01:05 PM UTC

Hi Fernando,
Thanks for the update.
Please let us know if you have any further assistance.
 
Regards
Ayyanar

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

;