Monday, 16 July 2012

Hierarchical Data Grid Filtering - Excel Style

This sample demonstrates how to enable Excel-style filtering on the WebHierarchicalDataGrid control. Excel-style filtering gives users the option to select the search condition from a checkbox list with distinct values for the column. You can choose subset of the list items or all items. Note: Filtering is disabled on the child grid EmployeeID column.

Default.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/SamplePage.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="Samples_WebHierarchicalDataGrid_Organization_ExcelStyleFiltering_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
   <div style=" margin-top:30px; ">
    <ig:webhierarchicaldatagrid ID="WebHierarchicalDataGrid1" 
            DataSourceID="WebHierarchicalDataSource1" runat="server" Height="350px"
        Width="100%" DataKeyFields="CustomerID">
            <Behaviors>
                <ig:Activation Enabled="true">
                </ig:Activation>
                <ig:Filtering Enabled="true" EnableInheritance="true" FilterType="ExcelStyleFilter" />
            </Behaviors>
            <Bands>
                <ig:Band Key="Orders" DataMember="AccessDataSource2_Orders" DataKeyFields="OrderID">
                    <Behaviors>
                        <ig:Filtering FilterType="ExcelStyleFilter">
                            <ColumnSettings>
                                <ig:ColumnFilteringSetting ColumnKey="EmployeeID" Enabled="false" />
                            </ColumnSettings>
                        </ig:Filtering>
                    </Behaviors>
                </ig:Band>
            </Bands>
    </ig:webhierarchicaldatagrid>
    <ig:webhierarchicaldatasource ID="WebHierarchicalDataSource1" runat="server">
            <DataRelations>
                <ig:DataRelation ParentColumns="CustomerID" ParentDataViewID="AccessDataSource1_Customers"
                    ChildColumns="CustomerID" ChildDataViewID="AccessDataSource2_Orders" />
            </DataRelations>
            <DataViews>
                <ig:DataView ID="AccessDataSource1_Customers" DataSourceID="AccessDataSource1" />
                <ig:DataView ID="AccessDataSource2_Orders" DataSourceID="AccessDataSource2" />
            </DataViews>
        </ig:webhierarchicaldatasource>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile='<%# this.GetMdbLocation("NWind.mdb")%>'   
            SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle] FROM [Customers]">
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile='<%# this.GetMdbLocation("NWind.mdb")%>'      
            SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID], [OrderDate], [RequiredDate] FROM [Orders]">
        </asp:AccessDataSource>
        </div>
</asp:Content>

Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Samples_WebHierarchicalDataGrid_Organization_ExcelStyleFiltering_Default :  Infragistics.Web.SampleBrowser.Core.Framework.Web.UI.ASPNET.SamplePage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this.AccessDataSource1.DataBind();
        this.AccessDataSource2.DataBind();
    }
}
 
Default.aspx.vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Partial Class Samples_WebHierarchicalDataGrid_Organization_ExcelStyleFiltering_Default
    Inherits Infragistics.Web.SampleBrowser.Core.Framework.Web.UI.ASPNET.SamplePage
    Protected Overrides Sub OnInit(e As EventArgs)
        MyBase.OnInit(e)
        Me.AccessDataSource1.DataBind()
        Me.AccessDataSource2.DataBind()
    End Sub
End Class
  
Article provided by: 

No comments:

Post a Comment