Excel Filtering in Web Components Hierarchical Grid
The Web Components Hierarchical Grid exposes an Excel-style filtering feature that provides an Excel-like filtering UI. It simplifies the process of working with large datasets. The main idea is to help them filter the data that is most relevant, while eliminating irrelevant entries.
Web Components Hierarchical Grid Excel Style Filtering Example
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"primary-key="ID"allow-filtering="true"filter-mode="excelStyleFilter"name="hierarchicalGrid1"id="hierarchicalGrid1"><igc-grid-toolbar
><igc-grid-toolbar-actions
><igc-grid-toolbar-hiding
></igc-grid-toolbar-hiding><igc-grid-toolbar-pinning
></igc-grid-toolbar-pinning></igc-grid-toolbar-actions></igc-grid-toolbar><igc-columnfield="Artist"header="Artist"data-type="string"resizable="true"></igc-column><igc-columnfield="Photo"header="Photo"data-type="image"min-width="115px"resizable="true"></igc-column><igc-columnfield="Debut"header="Debut"data-type="number"min-width="88px"max-width="230px"resizable="true"filterable="false"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"data-type="string"resizable="true"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Album"header="Album"data-type="string"resizable="true"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"resizable="true"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"data-type="string"resizable="true"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Number"header="No."data-type="string"resizable="true"></igc-column><igc-columnfield="Title"header="Title"data-type="string"resizable="true"></igc-column><igc-columnfield="Released"header="Released"data-type="string"resizable="true"></igc-column><igc-columnfield="Genre"header="Genre"data-type="string"resizable="true"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Tour"header="Tour"data-type="string"resizable="true"></igc-column><igc-columnfield="StartedOn"header="Started on"data-type="string"resizable="true"></igc-column><igc-columnfield="Location"header="Location"data-type="string"resizable="true"></igc-column><igc-columnfield="Headliner"header="Headliner"data-type="string"resizable="true"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.
In order to open the filter menu for a particular column, the Web Components filter icon in the header should be clicked. Additionally, you can use the Ctrl + Shift + L combination on a selected header. If the column can be sorted, pinned, moved, selected or hidden along with the filtering functionality, there will be buttons available for the features that are turned on.
If no filter is applied, all the items in the list will be selected. They can be filtered from the input above the list. In order to filter the data, you can select/deselect the items in the list and either click the Apply button, or press Enter. The filtering applied through the list items creates filter expressions with equals operator and the logic operator between the expressions is OR.
If you type something in the search box and apply the filter, only the items that match the search criteria will be selected. If you want to add items to the currently filtered ones, however, you should select the option Add current selection to filter.
If you want to clear the filter, you can check the Select All option and then click the Apply button.
To apply a filter with different expressions, you can click the Text filter, which will open a sub menu with all available filter operators for the particular column. Selecting one of them will open the custom filter dialog, where you can add as many expressions as you want with different filter and logic operators. There is also a clear button, which can clear the filter.
In the sample below 'Artist' column have all three features enabled, 'Debut' have all three disabled, 'Grammy Nominations' has only pinning and hiding.
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"primary-key="ID"allow-filtering="true"filter-mode="excelStyleFilter"name="hierarchicalGrid1"id="hierarchicalGrid1"><igc-grid-toolbar
><igc-grid-toolbar-actions
><igc-grid-toolbar-hiding
></igc-grid-toolbar-hiding><igc-grid-toolbar-pinning
></igc-grid-toolbar-pinning></igc-grid-toolbar-actions></igc-grid-toolbar><igc-columnfield="Artist"header="Artist"data-type="string"resizable="true"sortable="true"></igc-column><igc-columnfield="Photo"header="Photo"data-type="image"min-width="115px"resizable="true"disable-pinning="true"disable-hiding="true"></igc-column><igc-columnfield="Debut"header="Debut"data-type="number"min-width="88px"max-width="230px"resizable="true"filterable="false"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"data-type="string"resizable="true"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Album"header="Album"data-type="string"resizable="true"sortable="true"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"resizable="true"disable-pinning="true"disable-hiding="true"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"data-type="string"resizable="true"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Number"header="No."data-type="string"resizable="true"></igc-column><igc-columnfield="Title"header="Title"data-type="string"resizable="true"></igc-column><igc-columnfield="Released"header="Released"data-type="string"resizable="true"></igc-column><igc-columnfield="Genre"header="Genre"data-type="string"resizable="true"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Tour"header="Tour"data-type="string"resizable="true"></igc-column><igc-columnfield="StartedOn"header="Started on"data-type="string"resizable="true"></igc-column><igc-columnfield="Location"header="Location"data-type="string"resizable="true"></igc-column><igc-columnfield="Headliner"header="Headliner"data-type="string"resizable="true"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Templates
If you want to further customize the Excel style filter menu, you can use the excelStyleHeaderIconTemplate property to define a custom template for the header icon of the menu.
The following code demonstrates how to customize the Excel style filter menu using the excelStyleHeaderIconTemplate:
constructor() {
var grid = this.grid = document.getElementById('grid') as IgcHierarchicalGridComponent;
grid.excelStyleHeaderIconTemplate = this.webGridFilterAltIconTemplate;
}
public webGridFilterAltIconTemplate = (ctx: IgcCellTemplateContext) => {
return html`<imgheight="15px"width="15px"src="http://static.infragistics.com/xplatform/images/grid/propeller-logo.svg"title="Continued"alt="Continued" />`
}
ts
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"primary-key="ID"allow-filtering="true"filter-mode="excelStyleFilter"name="hierarchicalGrid1"id="hierarchicalGrid1"><igc-grid-toolbar
><igc-grid-toolbar-actions
><igc-grid-toolbar-hiding
></igc-grid-toolbar-hiding><igc-grid-toolbar-pinning
></igc-grid-toolbar-pinning></igc-grid-toolbar-actions></igc-grid-toolbar><igc-columnfield="Artist"header="Artist"data-type="string"resizable="true"></igc-column><igc-columnfield="Photo"header="Photo"data-type="image"min-width="115px"resizable="true"></igc-column><igc-columnfield="Debut"header="Debut"data-type="number"min-width="88px"max-width="230px"resizable="true"filterable="false"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"data-type="string"resizable="true"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Album"header="Album"data-type="string"resizable="true"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"resizable="true"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"data-type="string"resizable="true"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Number"header="No."data-type="string"resizable="true"></igc-column><igc-columnfield="Title"header="Title"data-type="string"resizable="true"></igc-column><igc-columnfield="Released"header="Released"data-type="string"resizable="true"></igc-column><igc-columnfield="Genre"header="Genre"data-type="string"resizable="true"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Tour"header="Tour"data-type="string"resizable="true"></igc-column><igc-columnfield="StartedOn"header="Started on"data-type="string"resizable="true"></igc-column><igc-columnfield="Location"header="Location"data-type="string"resizable="true"></igc-column><igc-columnfield="Headliner"header="Headliner"data-type="string"resizable="true"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Styling
In addition to the predefined themes, the grid could be further customized by setting some of the available CSS properties.
In case you would like to change some of the colors, you need to set a class for the grid first:
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"id="grid"name="grid"id="grid"primary-key="ID"allow-filtering="true"filter-mode="excelStyleFilter"><igc-grid-toolbar
><igc-grid-toolbar-actions
><igc-grid-toolbar-hiding
></igc-grid-toolbar-hiding><igc-grid-toolbar-pinning
></igc-grid-toolbar-pinning></igc-grid-toolbar-actions></igc-grid-toolbar><igc-columnfield="Artist"header="Artist"data-type="string"resizable="true"></igc-column><igc-columnfield="Photo"header="Photo"data-type="image"min-width="115px"resizable="true"></igc-column><igc-columnfield="Debut"header="Debut"data-type="number"min-width="88px"max-width="230px"resizable="true"filterable="false"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"data-type="string"resizable="true"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Album"header="Album"data-type="string"resizable="true"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"resizable="true"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"data-type="string"resizable="true"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"data-type="string"resizable="true"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Number"header="No."data-type="string"resizable="true"></igc-column><igc-columnfield="Title"header="Title"data-type="string"resizable="true"></igc-column><igc-columnfield="Released"header="Released"data-type="string"resizable="true"></igc-column><igc-columnfield="Genre"header="Genre"data-type="string"resizable="true"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"allow-filtering="true"filter-mode="excelStyleFilter"><igc-columnfield="Tour"header="Tour"data-type="string"resizable="true"></igc-column><igc-columnfield="StartedOn"header="Started on"data-type="string"resizable="true"></igc-column><igc-columnfield="Location"header="Location"data-type="string"resizable="true"></igc-column><igc-columnfield="Headliner"header="Headliner"data-type="string"resizable="true"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html