GridView SearchRow capitalize

3 Answers 118 Views
GridView
özer
Top achievements
Rank 2
Veteran
Iron
özer asked on 29 Mar 2023, 01:20 PM

Hi.

I have a problem for GridView SearchRow. 

All text in my grid is capitalized. However, when I type in lowercase in the search box, there is a problem with non-English characters. I want lowercase "i" to change to uppercase "İ", but the search doesn't work properly because it turns into uppercase "I".

In this case, I either need to convert all my texts to uppercase, but I couldn't figure out how to do it. This process is very easy in the filter row, but I could not find a similar mechanism in the search row.

I think another option would be to change the cultur info of the grid (I'm not sure if there is such a thing)  but I couldn't figure out how to do that either.

 

Thank you in advance for your help

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Apr 2023, 06:57 AM

Hello, özer,

According to the provided information and screenshot, it seems that you need to search by lower case letters and find the capital case letters in the grid rows. Please correct me if I am wrong. It is possible to create a custom GridViewSearchRowInfo and override its MatchesSearchCriteria method which returns true/false. Thus, you can control which rows to match the filter. A sample approach how to plug into the search functionality and change the default logic is demonstrated here: 

https://docs.telerik.com/devtools/winforms/knowledge-base/starts-with-search-in-radgridview 

You can use it as a starting point for achieving the custom implementation you need.

It is possible to specify the Culture at application level by setting the System.Threading.Thread.CurrentThread.CurrentCulture property to the desired culture. It is also possible to specify a culture for a particular column in the grid by setting the column's FormatInfo property. Note that the search functionality in RadGridView is purposed to search for the matches considering the formatted cells' values /not the raw cell's value/ according to the applied culture to the column. It is worth considering the custom filtering functionality that RadGridView uses. In many cases, it is appropriate to replace the search functionality with the custom filtering like demonstrated in the following KB article:

https://docs.telerik.com/devtools/winforms/knowledge-base/grid-searching-in-formated-decimal-columns 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
özer
Top achievements
Rank 2
Veteran
Iron
answered on 06 Apr 2023, 08:40 AM | edited on 06 Apr 2023, 01:23 PM

Hi Dess. 

Sorry I'm a little late in responding.

I tried both methods but they didn't work.


public RadForm1()
{
    InitializeComponent();

    this.radGridView1.AllowSearchRow = true;

    this.radGridView1.CurrentRowChanging += RadGridView1_CurrentRowChanging;
}

private void RadGridView1_CurrentRowChanging(object sender, CurrentRowChangingEventArgs e)
{
    if (e.NewRow is GridViewSearchRowInfo)
    {
        e.Cancel = true; // I put a breakpoint here, but it never stopped here 
    }
}


private void radGridView1_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
{
    if (e.RowInfo is GridViewSearchRowInfo)
    {
         e.RowInfo = new CustomSearchRow(e.ViewInfo); //likewise i put a breakpoint here but it never stopped here either
    }
}

public class CustomSearchRow : GridViewSearchRowInfo
{
    public CustomSearchRow(GridViewInfo viewInfo) : base(viewInfo)
    {
    }

    protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col)
    {
        return (row.Cells[col.Name].Value + "").StartsWith(searchCriteria); 
    }
}

Changing the cultureinfo didn't work for me, unfortunately.

The keypress event of the grid is also not fired on the search row. It acts as if the search row is a separate component rather than a part of the grid.

Dess | Tech Support Engineer, Principal
Telerik team
commented on 06 Apr 2023, 12:26 PM

Hi, özer,

I have prepared a sample project for your reference. As it is noted in the article, it is important to subscribe to the CreateRowInfo event at design time. Thus, the CreateRowInfo event is expected to be fired when the AllowSearchRow property is set to true. Please give the sample project a try and let me know how it works on your end.

özer
Top achievements
Rank 2
Veteran
Iron
commented on 19 Apr 2023, 08:36 AM

Hi Dess. 

Sorry again I'm a little late in responding.

I had subscribed to the CreateRowInfo event at runtime, now fixed it as you said and subscribed at design time and I made a small change in the MatchesSearchCriteria method.


public class CustomSearchRow : GridViewSearchRowInfo
    {
        public CustomSearchRow(GridViewInfo viewInfo) : base(viewInfo)
        {
        }

        protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col)
        {
            searchCriteria = searchCriteria.ToUpper(); 
            return (row.Cells[col.Name].Value + "").Contains(searchCriteria);
        }
    }

The result serves its purpose, although not exactly what I want it to be. Thank you very much
0
özer
Top achievements
Rank 2
Veteran
Iron
answered on 16 Apr 2023, 03:56 PM

Hi Dess. 

Sorry again I'm a little late in responding.

I had subscribed to the CreateRowInfo event at runtime, now fixed it as you said and subscribed at design time and I made a small change in the MatchesSearchCriteria method.


public class CustomSearchRow : GridViewSearchRowInfo
    {
        public CustomSearchRow(GridViewInfo viewInfo) : base(viewInfo)
        {
        }

        protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col)
        {
            searchCriteria = searchCriteria.ToUpper(); 
            return (row.Cells[col.Name].Value + "").Contains(searchCriteria);
        }
    }

The result serves its purpose, although not exactly what I want it to be. Thank you very much

 

 

 

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 21 Apr 2023, 03:24 PM

Hi, özer,

I reviewed the sample video. Please note that the MatchesSearchCriteria method indicates whether a row matches the search criteria or not. But the highlighting is expected to be applied to the exact matches exactly since it is applied to the text blocks that meet the criteria. I hope that the achieved result is acceptable for your case.

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