<SfGrid ID="Grid" @ref="Grid" DataSource="this.ProductList" AllowFiltering="true">
                <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
                    <GridColumn Field=@nameof(Product.ProductType) HeaderText="Product Type" Width="200" AllowEditing="false">
                        <FilterTemplate>
                            <SfDropDownList PlaceHolder="All" DataSource="@ProductCategoryList" TValue="string" TItem="ProductCategory">
                                <DropDownListEvents ValueChange="ProductTypeFilterChanged" TItem="ProductCategory" TValue="string"></DropDownListEvents>
                                <DropDownListFieldSettings Value="Name" Text="Name"></DropDownListFieldSettings>
                            </SfDropDownList>
                        </FilterTemplate>
                    </GridColumn>
        public SfGrid<CustomersdbShared.Models.Product> Grid;

        public async Task ProductTypeFilterChanged(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, ProductCategory> args)
        {
            Console.WriteLine("ProductTypeFilterChanged: " + args.Value);

            if (args.Value == "All")
            {
                await this.Grid.ClearFiltering("ProductType");
            }
            else
            {
                await this.Grid.FilterByColumn("ProductType", "contains", args.Value);
            }
        }
Last modified: February 28, 2021

Author

Comments

Write a Reply or Comment