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

SearchRow Buttons not working with custom search criteria

3 Answers 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Curtis asked on 03 Sep 2020, 03:57 AM

First the problem I am trying to solve:  gridview's SearchRow by default uses "Contains" for GridViewTextBoxColumns.  I need to change this to "Starts With"

I searched the KB and found this article: https://docs.telerik.com/devtools/winforms/knowledge-base/starts-with-search-in-radgridview and its ALMOST perfect!

It was VERY easy to implement and it works...sort of :(

 

Ok so it works "sort of" and you get only the rows that "Start With" that match whatever you typed into the Search Row (I have AutomaticallySelectFirstResult = True.)

Now click the "next" or "previous" button on the search row...nothing happens or rather it happens in the blink of an eye:  The first row that matches is selected from the search.  Click Next and it deselects that first row...and then reselects it.  If you click the "Previous" button it will in fact jump to the very last match.  Click it again and it clears the selection, and re-selects the same row.  It does not crawl through the collection of found results :(

 

The expected behavior would be the grid selects the next row when you click the "Next" button.  Click this again and again the grid should select the next row that matches and so on.  Same for the "Previous" button only in reverse.  Finding a solution to this is my immediate problem.

 

More on the "Sort of" working new custom search - what the article describes is creating a class called "CustomSearchRow" and there's an overridden method contained within called "MatchesSearchCriteria" and this returns a Boolean that if the cell "StartsWith" returns True and False otherwise...here's why I say it "Sort of" works:  If you have a cell with "All Good People" and you search for "P" it WILL find this...that cell does NOT start with "P", it starts with "A" and should NOT be found.  If anyone knows a way around this your help would terrific!

 

-Curtis

 

3 Answers, 1 is accepted

Sort by
0
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 03 Sep 2020, 04:04 AM

*UPDATE* The last issue in my post seems to be a non-issue.  The description of how the search was finding characters within comes from the KB Article itself you can see from the screenshots within the article.  This does not seem to be the behavior of the most recent Telerik libraries.  I would edit my original thread-post but i'm not seeing how so this will have to suffice.

My original problem with the buttons not working has been confirmed.

I apologize for the confusion.

 

0
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 04 Sep 2020, 07:11 PM
Still unable to figure this one out folks - anyone have any thoughts?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Sep 2020, 06:55 AM

Hello, Curtis,

Following the provided information, I have created a sample project using the approach in the referred KB article. Indeed, when using the custom search row, the next/previous button don't behave as expected.

The possible solution that I can suggest is to cancel the CurrentRowChanging event when the new row is the GridViewSearchRowInfo:
    Sub New()

        InitializeComponent()

        Me.RadGridView1.AllowSearchRow = True

        AddHandler Me.RadGridView1.CurrentRowChanging, AddressOf RadGridView1_CurrentRowChanging
    End Sub

    Private Sub RadGridView1_CurrentRowChanging(sender As Object, e As CurrentRowChangingEventArgs)
        If TypeOf e.NewRow Is GridViewSearchRowInfo Then
            e.Cancel = True
        End If
    End Sub

It seems to work as expected on my end with the latest version.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or