Intersoft WebGrid Documentation
CustomFilter Event
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > WebGrid Class : CustomFilter Event






Occurs when custom filtering is performed on WebGridColumn.

Syntax

Visual Basic (Declaration) 
<CategoryAttribute("Behavior")>
<DescriptionAttribute()>
Public Event CustomFilter As CustomFilterEventHandler
Visual Basic (Usage)Copy Code
Dim instance As WebGrid
Dim handler As CustomFilterEventHandler
 
AddHandler instance.CustomFilter, handler
C# 
[CategoryAttribute("Behavior")]
[DescriptionAttribute()]
public event CustomFilterEventHandler CustomFilter
Delphi 
public event CustomFilter: CustomFilterEventHandler; 
JScript 
In JScript, you can handle the events defined by another class, but you cannot define your own.
Managed Extensions for C++ 
[CategoryAttribute("Behavior")]
[DescriptionAttribute()]
public: __event CustomFilterEventHandler* CustomFilter
C++/CLI 
[CategoryAttribute("Behavior")]
[DescriptionAttribute()]
public:
event CustomFilterEventHandler^ CustomFilter

Event Data

The event handler receives an argument of type FilterEventArgs containing data related to this event. The following FilterEventArgs properties provide information specific to this event.

PropertyDescription
DataSource Gets the DataSource used by the event.
FilterColumns Gets the WebGridFilterCollection object used by the event.
ReturnValue (Inherited from ISNet.WebUI.WebGrid.BaseEventArgs) 
Table Gets the WebGridTable object used by the event.

Example

 

The following example shows you how to do the custom filtering. The first step is you need to set the AllowFilter, AllowEdit and AllowSorting property to True, then you need to bind the datasource in WebGrid. After that you need to create or set WebValueList in InitializeLayout event. Finally, you need to add the code in CustomFilter event. When a filter or more is applied to the grid, it will check the column with WebValueList applied to it and then do some manipulation on how data is suppose to be filtered. What it actually does is it filters a column which is not rendered in the grid, not the column you thought you are filtering.
C#Copy Code
private void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    oleDbDataAdapter1.Fill(dsNorthWind1.Products);
    e.DataSource = dsNorthWind1;
}

private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
{
     WebValueList wvalue = WebGrid1.RootTable.Columns.GetNamedItem("CategoryID").ValueList;
     if(!wvalue.IsDataCached())
     {
             oleDbDataAdapter2.Fill(dsNorthWind1.Categories);
             wvalue.DataSource = dsNorthWind1;
     }
     wvalue.DataMember = "Categories";
     wvalue.DataTextField = "CategoryName";
     wvalue.DataValueField = "CategoryID";
}

private void WebGrid1_CustomFilter(object sender, ISNet.WebUI.WebGrid.FilterEventArgs e)
{
     WebGridFilter filter;
     filter = e.FilterColumns.GetNamedItem("CategoryName");
     if (filter!=null)
     e.FilterColumns.Remove(filter);

     WebGridFilter oldFilter;
     oldFilter = e.FilterColumns.GetNamedItem("CategoryID");
     if (oldFilter!=null)
     {
         e.FilterColumns.Remove(oldFilter);
         filter = new WebGridFilter();
         filter.Table = oldFilter.Table;
         // remember to set column member field BEFORE FilterType and FilterText
         filter.ColumnMember = "CategoryName";
         filter.FilterType = oldFilter.FilterType;
         filter.FilterText = oldFilter.FilterText;
         e.FilterColumns.Add(filter);
      }
}

Remarks

This event would allow users to filter a column which is not rendered in the grid. Users can manipulate on how data is suppose to be filtered using WebValueList.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.