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

How to change the full text search behavior?

6 Answers 778 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gert
Top achievements
Rank 1
Gert asked on 21 Jan 2020, 09:36 AM

Hi,

is it possible to change the full text search behavior from contains to start with?

The users whant e.g. to search vor zip codes and they do not want to see a lot of other results... pls see attached pic.

 

If it is possible is it also possible to switch the behavior at run time? Than I could provide a checkbox where the user can switch back to "contains-mode".

 

Thanks for help!!!

BR Gert

 

6 Answers, 1 is accepted

Sort by
0
Gert
Top achievements
Rank 1
answered on 21 Jan 2020, 09:39 AM
Using 2018.2.515.45
0
Vladimir Stoyanov
Telerik team
answered on 24 Jan 2020, 09:06 AM

Hello Gert,

Thank you for the provided picture. 

I am afraid that the search as you type functionality does not support searching in "startswith" mode. That said, I can suggest a couple of alternatives:

- You can exclude the other columns from the search: Exclude Column from Search.

- You can use the FilterRow FilteringMode.

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gert
Top achievements
Rank 1
answered on 24 Jan 2020, 09:45 AM

Sorry but both alternatives are not suitable for my requirements.

Is there a way to access the filter result programmatically to refilter it in code?

0
Accepted
Vladimir Stoyanov
Telerik team
answered on 28 Jan 2020, 02:36 PM

Hello Gert,

If the provided suggestions are not suitable for your scenario, you can consider canceling the Searching event and manually filtering the RadGridView. In order for the results to be highlighted, you can use the approach suggested in the following example: HighlightCustomColumn.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gert
Top achievements
Rank 1
answered on 28 Feb 2020, 12:12 PM

Hi Vladimir,

in the meantime I come up with a solution wich is working wery good, maybe some one else find this useful.

I set a cutom style in our lookup window for the search area within a combobox to select a certain column or all and a combobox to set the search mode and a TextBox for the filtering text .(LOV1.jpg)

And on the TextChanged-Event I add a CompositeFilterDescriptor on that GridView like:

private void AllColumnMode(System.Windows.Controls.TextBox tb, LOVBase dc)
{
    LovGridView.ClearAllFilter();
 
    var lovColumns = dc.Data.First().GetType().GetProperties();
    Telerik.Windows.Data.CompositeFilterDescriptor sumFilter =  new  Telerik.Windows.Data.CompositeFilterDescriptor();
    sumFilter.LogicalOperator = Telerik.Windows.Data.FilterCompositionLogicalOperator.Or;
 
    foreach (var col in lovColumns)
    {
        if (col.CustomAttributes.Count() > 0)
        {
            var realColName = ColDict.First(q => q.Key == col.Name).Value;
            if (selectedColumn == "All" || selectedColumn == realColName)
            {
                Telerik.Windows.Data.FilterOperator filterMode;
 
                if (selectedMode == "Starts With")
                    filterMode = Telerik.Windows.Data.FilterOperator.StartsWith;
                else
                    filterMode = Telerik.Windows.Data.FilterOperator.Contains;
 
                Telerik.Windows.Data.FilterDescriptor colFilter = new Telerik.Windows.Data.FilterDescriptor(col.Name, filterMode, tb.Text.ToUpper());
                colFilter.IsCaseSensitive = false;
                sumFilter.FilterDescriptors.Add(colFilter);
            }
        }
    }
 
    Telerik.Windows.Data.CompositeFilterDescriptor mainFilter = new Telerik.Windows.Data.CompositeFilterDescriptor();
    mainFilter.FilterDescriptors.Add(sumFilter);
 
    // Filters are working only for string columns! else exception: Input string was not in a correct format.
    try { LovGridView.FilterDescriptors.Add(mainFilter); } catch (Exception) { }
}

 

 

BR Gert

 

 

 

 

 

 

0
Vladimir Stoyanov
Telerik team
answered on 04 Mar 2020, 08:14 AM

Hello Gert,

I am glad to hear that you have found a suitable approach for your scenario. Thank you for sharing it with the community. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Gert
Top achievements
Rank 1
Answers by
Gert
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or