Filter - Contains not working

7 posts, 0 answers
  1. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 26 Mar Link to this post

    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.
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Mar Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 28 Mar in reply to Viktor Tachev Link to this post

    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>
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 29 Mar Link to this post

    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.
  6. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 30 Mar in reply to Viktor Tachev Link to this post

    Hi,

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

  7. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 30 Mar in reply to Developer Link to this post

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

     

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

  8. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 31 Mar Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017