This is a migrated thread and some comments may be shown as answers.

Filter with zeros in data

7 Answers 18 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 25 Apr 2011, 01:13 PM
 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?

7 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 25 Apr 2011, 04:29 PM
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
0
Vincent
Top achievements
Rank 1
answered on 26 Apr 2011, 01:08 AM
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.
0
Pavel Pavlov
Telerik team
answered on 26 Apr 2011, 09:19 AM
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
0
Vincent
Top achievements
Rank 1
answered on 26 Apr 2011, 10:19 AM
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... :):):)
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2011, 10:05 AM
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
0
Vincent
Top achievements
Rank 1
answered on 29 Apr 2011, 02:18 PM
HI!

Thank you Telerik!

When will you update the example in your site? :)
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2011, 02:23 PM
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
Tags
DataFilter
Asked by
Vincent
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or