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

Search as you Type example - Revisited

8 Answers 236 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Byron
Top achievements
Rank 1
Byron asked on 24 Jul 2009, 02:24 PM
Question, I'm working on adding a version of "search as you type". However in this case there are numeric columns that are bound to this grid with aggregates on those columns.

So, what is happening right now, is upon binding the grid will populate and display its data just fine, but when I attempt to "search as you type", the overridden CreateFilterExpression() throws an FormatException was unhanded by user code "Input string was not in a correct format" error.

This is only happening when I bind a column of type double on the grid.....as I mentioned, there are aggregates on those columns, so I'd like to leave them as numeric types.

Any thoughts on a workaround or what I may be doing wrong? If you use the example from the demos section of your site and add a column of type double to the grid, I'm guessing you'll get the same error.

Byron



8 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 30 Jul 2009, 08:32 AM
Hello Byron,

When you set the Value property of FilterDescriptor it should be of the correct type for the specific column. I'm sending you an updated version of the Search As You Type example to illustrate how to achieve this.

Hope this helps.

Kind regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kamachi Ravichandran
Top achievements
Rank 1
answered on 14 Aug 2009, 01:06 PM
Thanks for the code Byron, you solution works with string and numeric columns but doesn't work with DateTime, is there a work around?

thanks,
Ravi
0
Rana Pratap
Top achievements
Rank 1
answered on 28 Oct 2009, 04:03 PM
Hi,

I am using Rad Controls for silverlight Q2 2009, Even i am also facing the same issue for date time column, can anyone please reply to this thread and provide with sample code.

Thanks in advance

Rana pratap
0
Kamachi Ravichandran
Top achievements
Rank 1
answered on 28 Oct 2009, 04:13 PM
Try this and see if it works.

private void UpdateCompositeFilterValues()    
{    
    foreach (FilterDescriptor descriptor in this.compositeFilterDesriptor.FilterDescriptors)    
    {    
        object convertedValue = DefaultValue(descriptor.MemberType);    
    
        try    
        {    
            convertedValue = Convert.ChangeType(this.FilterValue, descriptor.MemberType);    
        }    
        catch    
        {    
        }    
    
        //Handler DateTime with simple try parse    
        if (descriptor.MemberType == typeof(DateTime))    
        {    
            DateTime date;    
            if (DateTime.TryParse(this.FilterValue, out date))    
            {    
                convertedValue = date;        
            }    
                
        }    
    
        descriptor.Value = convertedValue;    
    }    
}    
 
0
Romell
Top achievements
Rank 1
answered on 01 Aug 2012, 02:48 PM
Hi

This code works fine from c #, but to convert it to VB.NET I found a couple of details, most unimportant things and very easy decision, but I have a functional level error on line # 2:

line
        'Changed code to validate only against a column
         # 1 - Me.filterDescriptor = New CustomFilterDescriptor (Me.myDataGrid.Columns (5))
         # 2 - Me.myDataGrid.FilterDescriptors.Add (Me.filterDescriptor)

error
Can not change ObservableCollection CollectionChanged During's event.

Can you help with this case? Or better yet ....

You can provide me a simple example (not including classes) from vb to allow me to do a search as you type easily .... I can perhaps serve as a guide ....???

Thank you in advance .....
0
Romell
Top achievements
Rank 1
answered on 01 Aug 2012, 02:49 PM
Hi

This code works fine from c #, but to convert it to VB.NET I found a couple of details, most unimportant things and very easy decision, but I have a functional level error on line # 2:

line
        'Changed code to validate only against a column
         # 1 - Me.filterDescriptor = New CustomFilterDescriptor (Me.myDataGrid.Columns (5))
         # 2 - Me.myDataGrid.FilterDescriptors.Add (Me.filterDescriptor)

error
Can not change ObservableCollection CollectionChanged During's event.

Can you help with this case? Or better yet ....

You can provide me a simple example (not including classes) from vb to allow me to do a search as you type easily .... I can perhaps serve as a guide ....???

Thank you in advance .....
0
Rossen Hristov
Telerik team
answered on 01 Aug 2012, 03:02 PM
Hello,

First, you should read this topic to understand how filtering works.


After you know how filtering works, you can check this and this online examples. There is VB tab in the source view. Don't worry that they are for Silverlight -- we share 100% the same code base between WPF and Silverlight so everything is 100% the same. Examine these examples in order to understand their. Also, feel free to cover any other filtering topics from our documentation. They are pretty extensive.

I hope this helps.

All the best,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Romell
Top achievements
Rank 1
answered on 01 Aug 2012, 04:22 PM
Excellent coaching Ross!

Certainly I need understand the foundations of logic and functionality of the classes.

Thanks
Tags
GridView
Asked by
Byron
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Kamachi Ravichandran
Top achievements
Rank 1
Rana Pratap
Top achievements
Rank 1
Romell
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or