Set CurrentFilterFunction to NoFilter when user deletes filter value

4 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Jun 2010

    Posted 16 Jun 2010 Link to this post

    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.
  2. Martin
    Admin
    Martin avatar
    811 posts

    Posted 22 Jun 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave Thresher
    Dave Thresher avatar
    1 posts
    Member since:
    Jan 2010

    Posted 22 Jun 2010 Link to this post

    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.
  5. Martin
    Admin
    Martin avatar
    811 posts

    Posted 23 Jun 2010 Link to this post

    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
Back to Top