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

Set CurrentFilterFunction to NoFilter when user deletes filter value

3 Answers 163 Views
Filter
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 16 Jun 2010, 06:49 PM
I need to be able to set the CurrentFilterFunction to NoFilter when the user deletes the value without manually selecting the NoFilter option from the menu.  The following code is useless since the CurrentFilterValue contains the value that was deleted.

            foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
            {
                if (column.CurrentFilterFunction != GridKnownFunction.NoFilter
                && string.IsNullOrEmpty(column.CurrentFilterValue))
                {
                    column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                }
            }

Here is the description from the tester: If you enter a value in a filter field and highlight thevalue and hit the delete key then enter a value in a different filter and selectthe filter icon… the first value you entered and deleted re-appears and isincluded in the filter.

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 22 Jun 2010, 07:33 AM
Hello David,

One approach you can try is to wire the grid's ItemCreated event, find the filtering text box for a particular column and hook up its onblur client-side event. Then on the client check whether the control is empty and call the MasterTableView filter() client-side method. Here are sample code snippets:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem item = e.Item as GridFilteringItem;
        TextBox textBox = item["MyColumnUniqueName"].Controls[0] as TextBox;
        textBox.Attributes["onblur"] = "Blur(this, 'MyColumnUniqueName')";
    }
}

Javascript:

function Blur(textBox, columnUniqueName)
{
    if (textBox.value == "")
    {
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        masterTable.filter(columnUniqueName, "", Telerik.Web.UI.GridFilterFunction.NoFilter);
    }
}

I hope this helps,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave Thresher
Top achievements
Rank 1
answered on 22 Jun 2010, 06:30 PM
Martin,

This solution is very close, but the masterTable.filter() function is sending a postback and any other filters the user has typed in but not registered (applying the filter value using the dropdown menu) are erased.  This is just as bad as when the value won't erase.

I have an open bug report - ID:320326 and have been working with Tsvetoslav, but have been unable to convey that the filters clear out automatically for date and numeric columns, just not text.  Our application only uses databound columns (as designed), so all the filters are text filters.
0
Martin
Telerik team
answered on 23 Jun 2010, 04:07 PM
Hello Dave Thresher,

I have noticed that my colleague Tsvetoslav has already answered to your support ticket. To avoid duplicate posts I would suggest that you continue your communication in the support ticket. Here I am pasting his answer in order to make it available for the public:

"Hi Dave,

Thanks for the clarification.

You are correct in your observation. Unfortunately, this different behavior has been implemented into the corresponding columns by design and for reasons of avoiding the introduction of breaking changes our development team has opted not to unify the behavior in question across all columns.

I am sending you the previous sample modified along the lines of your requirement. Please, review it once again and do let us know how it goes."


Regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Filter
Asked by
David
Top achievements
Rank 1
Answers by
Martin
Telerik team
Dave Thresher
Top achievements
Rank 1
Share this question
or