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

Disable search list on Excel Filtering column

3 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Apr 2012, 07:56 PM
I'm using the Excel Filtering for my columns. Problem is when I have loaded a large number of items with unique date/time stamps it takes too long to populate the Excel-style filter, instead I'd like just display the 'Available Filters' list. This Excel list feature is useful on the other columns that have a limited number of disctinct values, however.

My question is can I enable/disable the search list in Excel Filtering by column (enabled for some, disabled for others)?

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 21 Apr 2012, 03:05 PM
Hello John,

Thank you for writing. 

Please consider the following code snippet, which demonstrates how to hide all elements in the popup, except the "Clear Filter" and the "Available Filters" items:
void radGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e)
{
    RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
    if (popup != null)
    {
        foreach (RadMenuItemBase item in popup.Items)
        {
            if (!(item is RadFilterOperationMenuItem) && !(item is RadMenuItem))
            {
                item.Visibility = ElementVisibility.Collapsed;
            }
        }
        popup.Size = new Size(popup.Width, 50);
        popup.SizingGrip.Visibility = ElementVisibility.Collapsed;
    }
}

I hope that you find this information useful. Let us know if you have any other questions.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
John
Top achievements
Rank 1
answered on 24 Apr 2012, 05:12 PM

Thanks for the response. My column that I'm attempting to filter is of type DateTimeOffset, which doesn't get the default CalendarPopUp for DateTime columns, which I'd prefer. I've tried overriding this default but I get a runtime error:

if (e.Column.Name == "DetailTimeStamp")
  {
      e.FilterPopup = new RadDateFilterPopup(e.Column);
  }




Using the 'List Filter' style and removing the 'search filter' works, but one thing to note is that it appears changing the height of the filter popup is 'sticky' for other columns and requires resetting - even for other grids on the form that I'm not handling this event. So I changed the code as displayed below and I'll need to handle the event on other grids on my form as well.

private void grdViewSbycLatencyDetail_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
      {
          RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
          if (popup != null && e.Column.Name == "DetailTimeStamp")
          {
              foreach (RadMenuItemBase item in popup.Items)
              {
                  if (!(item is RadFilterOperationMenuItem) && !(item is RadMenuItem))
                  {
                      item.Visibility = ElementVisibility.Collapsed;
                  }
              }
              popup.Size = new System.Drawing.Size(popup.Width, 50);
              popup.SizingGrip.Visibility = ElementVisibility.Collapsed;
          }
          else
          {
              popup.Size = new System.Drawing.Size(popup.Width, 250);
              popup.SizingGrip.Visibility = ElementVisibility.Collapsed;
          }
 
      }
0
Stefan
Telerik team
answered on 27 Apr 2012, 12:55 PM
Hi John,

Thank you for writing back.

Indeed, you cannot use the calendar popup, because its calendar and the rest of the options there are using DateTime as a type and comparison between DataTime and DateTimeOffset is not supported. 

In regards to the popup size, you can work around this case by saving the initial popup size in a variable and use this variable for popup size, for columns different that the DateTimeOffset column:
Size saveSize;
void radGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e)
{
    e.FilterPopup = new RadListFilterPopup(e.Column);
    RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
    if (popup != null)
    {
        if (e.Column.Name == "DateColumn")
        {
            foreach (RadMenuItemBase item in popup.Items)
            {
                if (!(item is RadFilterOperationMenuItem) && !(item is RadMenuItem))
                {
                    item.Visibility = ElementVisibility.Collapsed;
                }
            }
            saveSize = popup.Size;
            popup.Size = new Size(popup.Width, 50);
            popup.SizingGrip.Visibility = ElementVisibility.Collapsed;
        }
        else
        {
            if (saveSize != Size.Empty)
            popup.Size = saveSize;
        }
    }

I hope this helps.

Regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Stefan
Telerik team
John
Top achievements
Rank 1
Share this question
or