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

Filter - Contains not working

6 Answers 357 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 26 Mar 2016, 09:58 PM
Hi,
I have a radgrid.  Within this I have enabled filtering.   I have set the filter type to Combined. 
In the gridboundcolumn I have specified ‘Contains’ as the CurrentFilterFunction.  However despite this when I filter the column I only ever get rows returned that exactly match the filter, so I presume it’s enforcing an ‘EqualsTo’ filter.
Is this by design or a bug?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 Mar 2016, 11:49 AM
Hello,

The behavior you describe seems rather strange. It would be hard to pinpoint what is causing it without additional investigation.

Would you send us a sample project where the behavior is reproduced? Thus, we will be able to examine the code locally and look for what can cause the behavior.

Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Developer
Top achievements
Rank 1
answered on 28 Mar 2016, 12:06 PM
Hello Viktor,
I’ve tried to do some debug work to try and identify what the issue is.
If I manually type the filter expression into the textbox and just hit enter the filter works, but only as equalto
I’ve try to capture the filter expression by using the example as posted here

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/filtering/how-to/operate-with-the-filterexpression-manually

If I select the value from the checklist I get this
Current Filter function: '5' for column 'tc'
Entered pattern for search:

If I type it manually and then click enter I get
Current Filter function: 'EqualTo' for column 'tc'
Entered pattern for search: xyz
The code for the column is this:

                <telerik:GridBoundColumn DataField="tc"UniqueName="tc"HeaderText="Component"
                    FilterCheckListEnableLoadOnDemand="true" AutoPostBackOnFilter="True" CurrentFilterFunction="Contains"
                    Display="True"ReadOnly="False"AllowFiltering="True"HeaderStyle-Width="200px"
                    AllowSorting="False"ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
                    ItemStyle-VerticalAlign="Top">
                </telerik:GridBoundColumn>
0
Viktor Tachev
Telerik team
answered on 29 Mar 2016, 10:34 AM
Hello,

When using CheckList filtering the default behavior is to list the items that are equal to the selected values in the ListBox.

If you would like to change that behavior you can access the FilterExpression in the NeedDataSource handler and modify it.

Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Developer
Top achievements
Rank 1
answered on 30 Mar 2016, 09:05 AM

Hi,

Do you have an example of the code that would accomplish this please?

0
Developer
Top achievements
Rank 1
answered on 30 Mar 2016, 12:49 PM

I've tried this code, but it made no difference:

 

RadGrid1.Columns[1].CurrentFilterFunction = Telerik.Web.UI.GridKnownFunction.Contains;

0
Viktor Tachev
Telerik team
answered on 31 Mar 2016, 11:53 AM
Hi,

The code snippet below outlines how you can set the FilterExpression for the grid in the NeedDataSource handler:


protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    RadGrid1.DataSource = GetData();
 
    // set the filter expression according to your requirements
    string customFilterExpression = "(it[\"Name\"].ToString().Contains(\"4\"))";
    RadGrid1.MasterTableView.FilterExpression = customFilterExpression;
}


Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Developer
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Developer
Top achievements
Rank 1
Share this question
or