Filtering with ENTER in RadGrid only filter one column

2 posts, 0 answers
  1. Reto
    Reto avatar
    1 posts
    Member since:
    Nov 2012

    Posted 21 Nov 2012 Link to this post

    Hello everybody,

    We have a project that uses several RadGrids in many ASP sites. We created the RadGrid in an seperate UserControl and this works very well. Now I have an issue from a customer that concerns the filtering.

    Init / Problem:
    We enable the filtering by default in our colums and that's works good too. So the user can enter a value, then hit the TAB or ENTER key and the RadGrid filters with it's values. Now in some cases the user would like to enter all of the filter values first and start the filtering by pressing the ENTER key.

    I've searched a lot in your forums and found that some users had a similar problem. What I tested now is to add the folowing code (in the ItemDataBound event from the RadGrid) to prevent the execution of the filter by pressing the TAB key in the filter textbox or loosing it's focus.

    filterBox.Attributes.Add("OnChange", "javascript:return false;")

    Now this works also very well and the filtering start by pressing the ENTER button, but I figured out that this not solve my problem. Because when I enter a filter value in 2 or more colums only the last entered value will be filtered and sometimes the filter is cleared and the RadGrid is not filtered.

    You can see this behavior in this demo project provided from "Tsventina" (Link: Filtering on ENTER key). Please notice that we use the last release of the Telerik Controls but the behavior is the same.

    You can see the problem by testing as follows:
    1. Enter value in column "ContactName" and press ENTER -> Result: RadGrid is filtered OK
    2. Enter value in column "ContactName" and press TAB and then ENTER -> Result: Value in column is cleared, RadGrid is not filtered
    3. Enter value in column "ContactName" go to for e.g. column "Address" and enter a second filter value and press ENTER -> Result: Value in column "ContactName" is cleared, value in column "Address" is filtered.
    4. Enter value in column "ContactName" go to for e.g. column "Address" and enter a second filter value and press TAB (you're possibly in column "City") and then press ENTER -> Result: All filter values are gone, RadGrid is not filtered

    I hope you're understand what I'd like to say and it would be very nice if someone of you have a workarround for me.

    Thanks in advance.

    Best greetings from Switzerland

    PS: Maybe...sorry for my bad english :)
  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 26 Nov 2012 Link to this post


    As RadGrid's Filter command is designed to work with only one column at a time, your scenario could not be achieved out-of-the-box. What you need to do to solve this issue, is to use your own filter command (e.g. "MultiFilter"). Then in the ItemCommand event handler, you can check for this command, and manually construct the filter expression to pass to RadGrid. After that, rebinding should have your RadGrid filtered by the custom filter expression. You could check out the following help articles for additional information.
    Operating with the FilterExpression of Telerik RadGrid Manually.
    Custom Option for Filtering.

    Another possible solution is to use RadFilter control in order to implement multi-column filtering. You could check out the following example for a live demo.

    I also prepared a sample where I used the aforementioned suggestion and attached it to this thread. You could give it a try and implement a similar custom filtering.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top