The Ignite UI for Blazor Filtering in Blazor Tree Grid is a feature that allows for selectively displaying or hiding data based on specific criteria or conditions. There is a bound data container through which the IgbTreeGrid Component provides rich filtering API and all the filtering capabilities. The available filtering types here are three:
The sample below demonstrates IgbTreeGrid's Quick Filter user experience.
EXAMPLE
MODULES
DATA
RAZOR
CSS
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbTreeGridModule)
);
await builder.Build().RunAsync();
}
}
}cs
You can enable both the QuickFilter or ExcelStyleFilter and the advanced filtering user interfaces in the IgbTreeGrid. Both filtering user interfaces will work independently of one another. The final filtered result in the IgbTreeGrid is the intersection between the results of the two filters.
Interaction
In order to open the filter row for a particular column, the 'Filter' chip below its header should be clicked. To add conditions you should choose filter operand using the dropdown on the left of the input and enter value. For number and date columns 'Equals' is selected by default, for string - 'Contains' and for boolean - 'All'. Pressing 'Enter' confirms the condition and you are now able to add another one. There is a dropdown, between 'condition' chips, which determines the logical operator between them, 'AND' is selected by default. To remove a condition you can click the 'X' button of the chip, and to edit it you should select the chip and the input will be populated with the chip's data. While filter row is opened you can click on any filterable column's header in order to select it and to be able to add filter conditions for it.
While some filtering conditions have been applied to a column, and the filter row is closed, you can either remove the conditions by clicking the chip's close button, or you can open the filter row by selecting any of the chips. When there is not enough space to show all the conditions, a filter icon is shown with a badge that indicates how many more conditions there are. It can also be clicked in order to open the filter row.
Usage
There's a default filtering strategy provided out of the box, as well as all the standard filtering conditions, which the developer can replace with their own implementation. In addition, we've provided a way to easily plug in your own custom filtering conditions. The IgbTreeGrid currently provides not only a simplistic filtering UI, but also more complex filtering options. Depending on the set DataType of the column, the correct set of filtering operations is loaded inside the filter UI dropdown. Additionally, you can set the IgnoreCase and the initial Condition properties.
The filtering feature is enabled for the IgbTreeGrid component by setting the AllowFiltering input to true. The default FilterMode is QuickFilter and it cannot be changed run time. To disable this feature for a certain column – set the Filterable input to false.
If values of type string are used by a column of data type date, the IgbTreeGrid won't parse them to date objects and using filtering conditions won't be possible. If you want to use string objects, additional logic should be implemented on the application level, in order to parse the values to date objects.
The default value of AND returns only the rows that match all the currently applied filtering expressions. Following the example above, a row will be returned when both the 'ProductName' cell value contains 'myproduct' and the 'Price' cell value is greater than 55.
When set to OR, a row will be returned when either the 'ProductName' cell value contains 'myproduct' or the 'Price' cell value is greater than 55.
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:
<IgbTreeGridClass="grid"></IgbTreeGrid>razor
Then set the related CSS properties for that class:
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbTreeGridModule)
);
await builder.Build().RunAsync();
}
}
}cs
@using IgniteUI.Blazor.Controls<style>/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/#treeGrid {
--ig-grid-filtering-row-text-color: #292826;
--ig-grid-filtering-row-background: #ffcd0f;
--ig-grid-filtering-header-text-color: #292826;
--ig-grid-filtering-header-background: #ffcd0f;
}
</style><divclass="container vertical ig-typography"><divclass="container vertical fill"><IgbTreeGridAutoGenerate="false"Name="treeGrid"
@ref="treeGrid"Id="treeGrid"Data="OrdersData"FilterMode="FilterMode.QuickFilter"PrimaryKey="ID"ForeignKey="ParentID"AllowFiltering="true"><IgbColumnField="ID"Header="Order ID"DataType="GridColumnDataType.Number"></IgbColumn><IgbColumnField="Name"Header="Order Product"DataType="GridColumnDataType.String"></IgbColumn><IgbColumnField="Category"DataType="GridColumnDataType.String"></IgbColumn><IgbColumnField="Units"DataType="GridColumnDataType.Number"></IgbColumn><IgbColumnField="Age"DataType="GridColumnDataType.Number"Sortable="true"Hidden="true"></IgbColumn><IgbColumnField="UnitPrice"Header="Unit Price"DataType="GridColumnDataType.Currency"></IgbColumn><IgbColumnField="Price"DataType="GridColumnDataType.Currency"></IgbColumn><IgbColumnField="Country"DataType="GridColumnDataType.String"Sortable="true"></IgbColumn><IgbColumnField="OrderDate"Header="Order Date"DataType="GridColumnDataType.Date"></IgbColumn><IgbColumnField="Delivered"DataType="GridColumnDataType.Boolean"></IgbColumn></IgbTreeGrid></div></div>@code {protectedoverrideasync Task OnAfterRenderAsync(bool firstRender)
{
var treeGrid = this.treeGrid;
}
private IgbTreeGrid treeGrid;
private OrdersData _ordersData = null;
public OrdersData OrdersData
{
get
{
if (_ordersData == null)
{
_ordersData = new OrdersData();
}
return _ordersData;
}
}
}razor
/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/#treeGrid {
--ig-grid-filtering-row-text-color: #292826;
--ig-grid-filtering-row-background: #ffcd0f;
--ig-grid-filtering-header-text-color: #292826;
--ig-grid-filtering-header-background: #ffcd0f;
}
css
Known Limitations
Some browsers such as Firefox fail to parse regional specific decimal separators by considering them grouping separators, thus resulting in them being invalid. When inputting such values for a numeric column filter value, only the valid part of the number will be applied to the filtering expression. For further information, refer to the Firefox issue.