Filter with zeros in data

8 posts, 0 answers
  1. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 25 Apr 2011 Link to this post

     HI!

    Is there any way to filter zeroes in the RadGridView? i copied the exact code from your sample GridView: Search As You Type and unfortunately, it is not possible to filter the data containing 0s. I can't seem to find any zero-valued entry in your sample and i was wondering if this was intentional because the code cannot filter zeroes?
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Apr 2011 Link to this post

    Hello Vincent,

    Do you mean numeric zeros or nulls (nothing in VB)  ?

    Kind regards,
    Pavel Pavlov
    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. DevCraft banner
  4. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 25 Apr 2011 Link to this post

    I mean integral or numeric zeros. When there are columns with zero values. The filterdescriptor( or search) won't work. But, if there are no zero values in the datagrid, it perfectly works.
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 26 Apr 2011 Link to this post

    Hello Vincent,

    I have entered some zeroes in the online sample and tried filtering . It seems to work OK .
    Please check this http://screencast.com/t/3vN3hCIVhn . Am I missing something ?

    All the best,
    Pavel Pavlov
    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
  6. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 26 Apr 2011 Link to this post

    HI Telerik!

    Thank you for responding.

    I think I misstated the question.
    We have the same output as what you posted on the link. But, if we search for a certain string with zero values in another columns, the search filter would not work properly.

    To simplify this, can you try searching for "Wilmk" and "Tradh" in your example video.... What will be the outcome?

    I hope you'll reply... Thank you so much! If possible, please post again the video with your experiment... :):):)
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 29 Apr 2011 Link to this post

    Hi Vincent,

    Thanks for the clarifications! I was able to reproduce the erroneous behavior . Indeed there is some missing logic in the sample code .

    I was able to isolate it to the following method :
    private void UpdateCompositeFilterValues()
           {
               foreach (FilterDescriptor descriptor in this.compositeFilterDesriptor.FilterDescriptors)
               {
                   object convertedValue = DefaultValue(descriptor.MemberType);
                   try
                   {
                       convertedValue = Convert.ChangeType(this.FilterValue, descriptor.MemberType, CultureInfo.CurrentCulture);
                   }
                   catch
                   {
                   }
                   if (descriptor.MemberType.IsAssignableFrom(typeof(DateTime)))
                   {
                       DateTime date;
                       if (DateTime.TryParse(this.FilterValue, out date))
                       {
                           convertedValue = date;
                       }
                   }
                   descriptor.Value = convertedValue;
               }
           }

    When trying to convert the string value entered to numeric type for the numeric column , the code fails and falls back to the default value for the type - in this case 0. So an unneeded FilterDescriptor with value 0 is created.

    As a workaround I may suggest to exclude the numeric column when creating the FilterDescriptors.
    A simple check may be added to :
    foreach (GridViewDataColumn column in columns)
               {
                   this.compositeFilterDesriptor.FilterDescriptors.Add(this.CreateFilterForColumn(column));
               }

    in order to prevent adding a filter descriptor for the numeric column .

    Thank you for pointing our attention to that problem. We are going to update the online example.
    I am updating your Telerik points.

    Kind regards,
    Pavel Pavlov
    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
  8. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 29 Apr 2011 Link to this post

    HI!

    Thank you Telerik!

    When will you update the example in your site? :)
  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 29 Apr 2011 Link to this post

    Hi Vincent,

    Online examples  are updated on each official release. In our case this means the very next service pack .

    Regards,
    Pavel Pavlov
    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
Back to Top
DevCraft banner