We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Error when filtering by column (inherite)

@page "/"


@using Syncfusion.Blazor.DropDowns

<CustomGrid @ref="grid" TValue="Order" AllowFiltering="true">

    <SfDataManager AdaptorInstance="typeof(OrderDataAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>


    <GridColumns>

        <GridColumn Field=@nameof(Order.CustomerID) IsPrimaryKey="true" IsIdentity="true">

            <FilterTemplate>

                <SfDropDownList ID="filterCustomer" TValue="string" TItem="Customer" Placeholder="Select a role" ShowClearButton="true">

                    <SfDataManager AdaptorInstance="typeof(CustomerIdAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>

                    <DropDownListFieldSettings Text="@nameof(Customer.Name)" Value="@nameof(Customer.Id)" />

                    <DropDownListEvents TItem="Customer" TValue="string" ValueChange="@ValueChangeHandler" />

                </SfDropDownList>

            </FilterTemplate>


        </GridColumn>

        <GridColumn Field=@nameof(Order.OrderID) HeaderText="OrderID" Width="150"></GridColumn>

        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Width="150"></GridColumn>

        <GridColumn Field=@nameof(Order.OrderDate) HeaderText="OrderDate" Width="150">


        </GridColumn>


    </GridColumns>

</CustomGrid>


@code {


    CustomGrid<Order>? grid;

    // Exception here when Selected CustomerId IN Filter

    private async void ValueChangeHandler(ChangeEventArgs<string, Customer> obj)

    {

//Error

        await grid.FilterByColumnAsync("CustomerID", "equal", obj.Value, "CustomerID");

    }

}


Attachment: SfCustomGrid_bd715124.zip

1 Reply

MS Monisha Saravanan Syncfusion Team November 15, 2022 07:54 AM

Hi Kavit,


Greetings from Syncfusion.


We could see that in your shared sample while calling FilterByColumnsAsync method the Grid reference is not assigned properly. So we have modified the sample as per your shared requirement. Here we have handled the filtering on CustomGrid.razor.cs page. Kindly check the attached sample for below reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfCustomGrid2135479687.zip


Please let us know if you have any concerns.


Regards,

Monisha


Loader.
Live Chat Icon For mobile
Up arrow icon