DataFilter incorrectly filters long

3 posts, 1 answers
  1. jacob
    jacob avatar
    2 posts
    Member since:
    May 2011

    Posted 01 Jun 2011 Link to this post

    I have a DataFilter in tandem with a GridView to display data; one of the columns is ItemID (which is a long).  I want to filter on ItemID so I only see one value (say, 6917529027641130357  which I see as the first row); I use the DataFilter control and request ItemID is equal to 6917529027641130357 and all of the data is removed from the DataGrid.  In general, when I try to filter on any column which is a long, it doesn't find any data even though I know those IDs exist in the DataGrid; when I filter on any other columns, it appears to work just fine.  
    When I investigated the filters that the DataFilter was using, I see that there is one listed filter in FilterDescriptors and it is "ItemID IsEqualTo 6.91752902764113E+18"  which is clearly wrong: it has converted the ItemID to a float which is not the same value as the long I input.  If I manually change that value so the filter is  "ItemID IsEqualTo 6917529027641130357 ", I see the appropriate results show up in the DataGrid.  Is there a setting to make the DataFilter handle my input properly?  or is this a bug?

    Thanks for your help!
  2. Answer
    Rossen Hristov
    Rossen Hristov avatar
    2478 posts

    Posted 03 Jun 2011 Link to this post

    Hi jacob,

    When the member type is numeric as in your case, RadDataFilter will instantiate a RadMaskedText as its filter editor.

    Unfortunately, the RadMaskedTextBox works only with the System.Double value type for handling numeric and currency masks. So what it does is convert the Int64 to a Double.

    Precision will always be lost, as it uses double.ToString(this.Mask) to form the masked text. Parsing the masked text (on the way back) is done by double.Parse(…), which will also impact the precision.

    If you were using Int32, this should not be a problem.

    Currently, the only way to overcome this limitation of RadMaskedTextBox, will be to create a simple filter editor of your own. It can be a plain old TextBox that can handle long (Int64) values. 

    Here is an online demo that demonstrates how you can supply any kind of user control for the filter editor of RadDataFilter. You will supply a normal TextBox and you will set an IValueConverter on its Text-to-Value Binding that will convert the string that the user enters into an Int64. This should do the job.

    Please, excuse us for the inconvenience.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. jacob
    jacob avatar
    2 posts
    Member since:
    May 2011

    Posted 07 Jun 2011 Link to this post

    That works perfectly!  Thanks for your help!
Back to Top