Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Data Grid displays NaN for unset values, I need blank
posted

Hi, 

I am using a XamDataGrid to display double presision values. I need all Infinity or NaN values to display as BLANK. DataGrid displays NaN instead. Is there any way around this? I have tried various things, nothing worked so far. Maybe someone could post an example

Christos

  • 34430
    Offline posted

    Hello Christos,

    Thank you for contacting Infragistics Developer Support.

    I have been investigating into this behavior you are reporting and have built a sample based upon the code you have provided in support case CAS-188069-B7P8P7. After trimming down the styling code that you have provided, this appears to me to be an issue related to the IDataErrorInfo support for the XamDataGrid along with the Format property that is being set on your XamNumericEditor, as without either of these pieces, I cannot seem to reproduce this behavior you are seeing.

    It is also worth noting that I cannot seem to reproduce the behavior you are seeing unless I enter and exit edit mode on a cell that has either a double.NaN or Infinity-based value. At that point, I am seeing the behavior where either NaN or the infinity symbol will show up in the cell.

    This appears to be mainly due to the Format failing for the XamNumericEditor, since a Format of “0.0###” that you currently have applied expects an “actual” numeric value. It appears this is checked in the IDataErrorInfo support, and NaN or the infinity symbol is returned over the top of the ValueToDisplayTextConverter in this case, as this validation appears to happen after the ValueToDisplayTextConverter fires.

    In order to work around this, I would recommend that you create a DataTrigger in the Style for your XamNumericEditor and only apply a Format if the Value property of the XamNumericEditor is not NaN or Infinity-based. After doing this, I am no longer able to reproduce this behavior you are seeing.

    I am attaching a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XDGDoubleNANDisplayCase.zip