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

Clear Filter Descriptors text programatically

6 Answers 388 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 22 Feb 2015, 11:00 AM
Hi Folks ,

I have  telerik:RadGridView Data binded to QueryableCollectionView and I clear the descriptors using the following line 

MainGridVM.Data.FilterDescriptors.Clear();


it works fine but still the searched text appeared in FilterRow cell . How can I clear the filtered row too ?

6 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Feb 2015, 12:27 PM
Hi,

I would suggest you to check the Programmatic Filtering help article where you can find more information about how to clear RadGridView's filters.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mohammed
Top achievements
Rank 1
answered on 26 Feb 2015, 02:26 PM
Thanks Yoan ,

It works fine but it changed my default filter operator (Contains) and reset it to (Equal) do you know how to set it back to contains .?

Regards,
Mohammed Thabet 
0
Yoan
Telerik team
answered on 27 Feb 2015, 03:38 PM
Hello,

You can check the Change the Default Selected Filter Operators help article for a reference.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mohammed
Top achievements
Rank 1
answered on 04 Mar 2015, 09:19 AM
Thanks Yoan ,

We already used this event (OnRadGridViewFilterOperatorsLoading ) but we can not fire this event after reset filters so in columns loop we set default operator to (contains ) but my problem in case of DateTime columns (Contains) are not right so default operator for datetime columns should be (IsEqualTo)   .How to apply it in reset method ?

void grdRequests_OnResetFilters(object sender, EventArgs e)
        {
            grdRequests.FilterDescriptors.SuspendNotifications();
            foreach(var column in grdRequests.Columns)
            {
                column.SortingState = SortingState.None;
                column.ClearFilters();
                column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.Contains;
                
            }
            grdRequests.FilterDescriptors.ResumeNotifications();
        }

//////////////////////////////////////////

private void grdRequests_FilterOperatorsLoading(object sender, FilterOperatorsLoadingEventArgs e)
        {
            if (e.AvailableOperators.Contains(FilterOperator.Contains))
            {
                e.DefaultOperator1 = FilterOperator.Contains;
            }
            else if (e.AvailableOperators.Contains(FilterOperator.IsEqualTo))
            {
                e.DefaultOperator1 = FilterOperator.IsEqualTo;
            }

        }
0
Mohammed
Top achievements
Rank 1
answered on 04 Mar 2015, 12:53 PM
I just need to be clear that we did it on grdRequests_OnResetFilters() using AvailableOperators but I can not use it from gridcolumn . Just need to be clear in my question ,

Regards ,
Mohammed Thabet
0
Dimitrina
Telerik team
answered on 05 Mar 2015, 08:17 AM
Hi,

You will need to apply a similar logic when clearing the current filter.
For example:
grdRequests.FilterDescriptors.SuspendNotifications();
foreach (GridViewDataColumn column in grdRequests.Columns.OfType<GridViewDataColumn>())
{
    column.SortingState = SortingState.None;
    column.ClearFilters();
    var datatype = column.DataType;
    if (datatype == typeof(DateTime) || datatype == typeof(Int32))
    {
        column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.IsEqualTo;
    }
    else
    {
       column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.Contains;
    }
}
grdRequests.FilterDescriptors.ResumeNotifications();

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Mohammed
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or