Class FilteringEventArgs
Provides information about the Filtering event.
Inherited Members
Namespace: Syncfusion.Blazor.Grids
Assembly: Syncfusion.Blazor.dll
Syntax
public class FilteringEventArgs : FilteredEventArgs
Constructors
FilteringEventArgs()
Declaration
public FilteringEventArgs()
Properties
Cancel
Gets or sets a value indicating whether to cancel the filtering or clear filtering action in the grid.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is |
PreventFilterQuery
Gets or sets whether to prevent the grid column’s default filter query during the API call.
Declaration
public bool PreventFilterQuery { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is |
Remarks
By default, when a filter is applied to a grid column, the grid sends a default filter request with the column name and filter value to the server.
In some cases, the default filter request may be too long and exceed URL length limitations, resulting in a long URI exception. This property provides an option to generate a custom filter query for a specific grid column and override the default filter request.
To utilize this property, set it to true within this event, and then override the ProcessCustomFilterQuery
method in the adapter.
Examples
@implements IDisposable
<SfGrid AllowFiltering="true">
<GridEvents TValue="Book" CheckboxFilterSearch="CheckboxFilterSearchHandler" Filtering="FilteringHandler"/>
<GridForeignColumn @nameof(Book.CustomerId)>
<SfDataManager @ref="DataManagerRef" Url="http://localhost:64956/odata/customers" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
</GridForeignColumn>
</SfGrid>
@code{
SfGrid<Order> Grid;
public SfDataManager DataManagerRef { get; set; }
public static Query CustomQuery = new Query();
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
DataManagerRef.DataAdaptor = new TestOData(DataManagerRef);
}
base.OnAfterRender(firstRender);
}
void IDisposable.Dispose()
{
CustomQuery = null;
}
public class TestOData : ODataV4Adaptor
{
public TestOData(DataManager dm) : base(dm)
{
}
public override Query ProcessCustomFilterQuery(Query query)
{
return CustomQuery;
}
}
private void CheckboxFilterSearchHandler(CheckboxFilterSearchEventArgs args)
{
if (args.SearchText != string.Empty)
{
args.SearchText = string.Empty;
args.CheckboxListData = new List<Book>() { new Book() { Id = Guid.NewGuid(), CustomerId = Guid.NewGuid(), CustomerId1 = Guid.NewGuid(), Active = false, CreditLimit = 20 } };
}
}
private void FilteringHandler(Syncfusion.Blazor.Grids.FilteringEventArgs<Book> args)
{
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.ClearFiltering))
{
CustomQuery = new Query();
}
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Filtering)
{
if (String.Equals(args.ColumnName, null, StringComparison.OrdinalIgnoreCase) && String.Equals(args.FilterPredicate?.Field, "Name", StringComparison.OrdinalIgnoreCase))
{
CustomQuery = new Query();
}
if (String.Equals(args.ColumnName, nameof(Book.CustomerId), StringComparison.OrdinalIgnoreCase))
{
args.PreventFilterQuery = true;
List<WhereFilter> AndPredicate = new List<WhereFilter>();
if (args.FilterPredicates != null)
{
foreach (var col in args.FilterPredicates)
{
AndPredicate.Add(new WhereFilter() { Field = "Customer/Name", Operator = col.Operator.ToString().ToLower(), value = col.Value, Condition = col.Predicate });
}
if (AndPredicate[0].Condition == "and")
{
CustomQuery = new Query().Where(new WhereFilter() { Condition = "and", IsComplex = true, predicates = AndPredicate });
}
else
{
CustomQuery = new Query().Where(new WhereFilter() { Condition = "or", IsComplex = true, predicates = AndPredicate });
}
}
else if (args.FilterPredicates == null)
{
CustomQuery = new Query().Where("Customer/Name", args.CurrentFilterObject.Operator.ToString().ToLower(), args.CurrentFilterObject.Value, true, true);
}
}
}
}