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

Filter an Integer As String

6 Answers 305 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim Tos
Top achievements
Rank 1
Tim Tos asked on 16 Feb 2011, 08:28 PM
Hello.

I've got a GridView and a textbox.
The GridView has a databound column with integer values (for example: 111, 2222, 33333, 1234).
If the user now types into the textbox for example '2' only the rows with '2222' and '1234' should remain visible - the others are filtered out.

How can this be done? Is it possible to do it all with xaml and databinding?
I've looked at the custom FilterDescriptors but I couldn't wrap my head around it... - but I think I need one.

Thanks a lot!
Greetings and best wishes,
Tim.

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Feb 2011, 08:04 AM
Hello Tim Tos,

You may take a look at this and this blog posts for a reference.
 

Regards,
Maya
the Telerik team
0
Tim Tos
Top achievements
Rank 1
answered on 17 Feb 2011, 10:08 AM
Hello Maya,

thanks for your response but I think that's not the solution.
If I use your second link and change

_Items.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, _Text != null? _Text : ""));
to
_Items.FilterDescriptors.Add(new FilterDescriptor("ID", FilterOperator.Contains, _Text != null ? _Text : ""));

I get an exception. My column is an integer and for these there is no FilterOperator.Contains defined. I need some kind of "toString()".
So I want to have a StringFiltering with Contains for an integer...
Unfortunately I am not able to run the program of the first link. I get some kind of AG_E_Parse error...

Thanks again for your response!
Tim.
0
Maya
Telerik team
answered on 21 Feb 2011, 03:59 PM
Hi Tim Tos,

Depending on your particular settings, you may try to use one of the other FilterOperators instead of Contains. As far as the sample from the first link, it targets the Silverlight platform, but still you may follow the approach described.
Furthermore, you may take a look at our demos for a reference on implementing the "search-as-you-type" functionality.  

 
Greetings,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Tim Tos
Top achievements
Rank 1
answered on 21 Feb 2011, 04:08 PM
Hello Maya,

thanks again for answering!
But I need a Contains and cannot use the other FilterOperators.
My problem is not the "filtering as you type" - I've done that before and it worked great.
My problem is that I need Contains for an integer-bound column!!!

Thanks a lot for any help!
Greetings, Tim.
0
Accepted
Maya
Telerik team
answered on 22 Feb 2011, 06:20 PM
Hello Tim Tos,

Such a behavior may be achieved if you change the type of the underlaying property by calling ToString() method for example on those integer values. Afterwards the Contains operator will be applied accordingly.


All the best,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Tim Tos
Top achievements
Rank 1
answered on 23 Feb 2011, 02:43 PM
Hi Maya,

of course that'll work. I did hope that telerik got some built-in funcitonality.
Something like: "if is not string do .toString()..." Should be easy... ;)

But thanks a lot for your help!
Greetings and all the best,
Tim.
Tags
GridView
Asked by
Tim Tos
Top achievements
Rank 1
Answers by
Maya
Telerik team
Tim Tos
Top achievements
Rank 1
Share this question
or