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

CurrentFilterFunction is changed to "EqualTo" when filter by CheckList

4 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
adamhughes
Top achievements
Rank 1
Iron
Veteran
adamhughes asked on 19 Mar 2019, 09:30 PM

I am filtering at server side.

I am using FilterType="CheckList" for RadGrid and it works well (with default function "EqualTo").
There is a textbox for each column, I can input some text and filter CurrentFilterFunction="Contains".

Problem:
After filtering by CheckList, it changes the CurrentFilterFunction to "EqualTo".
So, I cannot filter with "Contains" function by textbox any more.

Proposed Solution:
There is any way to separate CurrentFilterFunction of CheckList filter and TextBox filter?

Grid:

<telerik:RadGrid Skin="Default" RenderMode="Lightweight" PageSize="20" runat="server" ID="RGridRisedueResultList" AllowPaging="true" AllowSorting="True" OnPreRender="RGridRisedueResultList_PreRender" OnFilterCheckListItemsRequested="RGridRisedueResultList_FilterCheckListItemsRequested" AutoGenerateColumns="False" FilterType="CheckList" AllowFilteringByColumn="True" OnNeedDataSource="RGridRisedueResultList_NeedDataSource">

 

Column:
<telerik:GridBoundColumn UniqueName="Lab" DataField="Lab" HeaderText="Lab" FilterCheckListEnableLoadOnDemand="true" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"> </telerik:GridBoundColumn>

 

4 Answers, 1 is accepted

Sort by
0
adamhughes
Top achievements
Rank 1
Iron
Veteran
answered on 19 Mar 2019, 10:09 PM
Filter by textbox is died until clear filter.
0
Attila Antal
Telerik team
answered on 22 Mar 2019, 03:02 PM
Hi Adam,

That is right, the Check List filter changes the FilterFunction to EqualTo, but you can change it back if it's no longer used. For example, as soon as clear filtering using the Check List, filter Function will get set back to Contains.

You can do that in the ItemCommand Event. Using this event, you can apply a condition to check for a specific command, then another condition that will check whether the CheckList has any filter applied. If not, that means, the check list is not in use, and therefore, switch back the filter function to "Contains":

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.FilterCommandName)
    {
        Pair args = e.CommandArgument as Pair;
 
        string filterFunction = args.First.ToString();
        string columnUniqueName = args.Second.ToString();
        GridColumn column = RadGrid1.MasterTableView.GetColumn(columnUniqueName);
 
        string[] filterValues = column.ListOfFilterValues;
 
        // if No filter is applied using the Filter CheckList
        if (filterValues == null || filterValues.Count() < 1)
        {
            // Change the Current Filter Function back to Contains
            column.CurrentFilterFunction = GridKnownFunction.Contains;
        }
    }
}


Kind regards,
Attila Antal
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
adamhughes
Top achievements
Rank 1
Iron
Veteran
answered on 24 Mar 2019, 09:29 PM

Thank you, Attila for the quick response.
Unfortunately, your suggestion does not solve my problem.

I am filtering by CheckList and TextBox on the same column.
Filtering by CheckBox is OK.
But, after that, I type some text then press Enter, the filtering does not work because CurrentFilterFunction is "EqualTo".

My idea to solve that problem:
If the TextBox has something, clear the current filter value, set filter function to "Contains".

Is there any config (no need code too much) to achieve that?

0
Attila Antal
Telerik team
answered on 27 Mar 2019, 09:28 PM
Hi Adam,

The required behavior is beyond the current built-in functionalities and changing this behavior requires custom code. The event handler and the example I have shared is the correct one for the behavior you want, but you will need to change the logic. Currently, the logic is checking, if there are no items checked in the CheckBoxList, then it changes the filter function back to Contains. If you revert that logic, or change the logic to check whether the Column has CurrentFilterValue, would then produce the exact behavior you are looking for.

Please give it a try and let us know if you are facing difficulties.

Kind regards,
Attila Antal
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
Grid
Asked by
adamhughes
Top achievements
Rank 1
Iron
Veteran
Answers by
adamhughes
Top achievements
Rank 1
Iron
Veteran
Attila Antal
Telerik team
Share this question
or