Cannot convert from Method Group to Event Callback for FilterTemplate DropDownList ValueChange event

I am using Syncfusion.Blazor v18.0.2.46

I am getting the error "cannot convert from 'method group' to 'EventCallback' when I try to reference a method in my code behind page to handle the ValueChange event in a Grid Column's FilterTemplate. I have been using this code in several components without getting the error but today, I am getting the error and cannot figure out why.

Here is the Grid markup;

        <SfGrid @ref="@Grid" TValue="TransactionActivity" AllowPaging="true" AllowFiltering="true" AllowSorting="true" Query="@TransactionActivityQuery">
            <GridEvents OnActionComplete="ActionCompleteHandler" TValue="TransactionActivity"></GridEvents>
            <GridPageSettings PageSize="@DefaultPageSize" PageSizes="@PageSizes"></GridPageSettings>
            <SfDataManager Headers="@HeaderData" Url="@CdApiUrl" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
            <GridSortSettings>
                <GridSortColumns>
                    <GridSortColumn Field="ActivityDate" Direction="SortDirection.Descending"></GridSortColumn>
                </GridSortColumns>
            </GridSortSettings>
            <GridColumns>
                <GridColumn HeaderText="" Width="175px" AllowFiltering="false">
                    <Template>
                        @{
                            var transactionActivity = (context as TransactionActivity);
                            if (IsAdmin)
                            {
                                <div class="text-center">
                                    <button Class="btn btn-outline-primary"
                                            @onclick="@(_ =>
                                              {
                                                  if (transactionActivity != null) HandleManageTransactionActivityClick(transactionActivity.Id);
                                              })">
                                        <span class="far fa-edit"></span> Manage
                                    </button>
                                </div>
                            }
                            else
                            {
                                <div class="text-center">
                                    <button Class="btn btn-outline-primary"
                                            @onclick="@(_ =>
                                              {
                                                  if (transactionActivity != null) HandleViewTransactionActivityClick(transactionActivity.Id);
                                              })">
                                        <span class="far fa-eye"></span> View
                                    </button>
                                </div>
                            }
                        }
                    </Template>
                </GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.AccountId) HeaderText="" Visible="false"></GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.ActivityDate) HeaderText="Activity Date" Format="d" Type="ColumnType.Date" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Center" Width="130">
                    <FilterTemplate>
                        <SfDatePicker @ref="ActivityDateFilter" TValue="DateTime?">
                            <DatePickerEvents ValueChange="@((args)=>HandleActivityDateChange(args))" TValue="DateTime?"></DatePickerEvents>
                        </SfDatePicker>
                    </FilterTemplate>
                </GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.TransactionType) HeaderText="Transaction Type" Width="175px">
                    <FilterTemplate>
                        <SfDropDownList Placeholder="Transaction Type" ID="TransactionType"
                                        Value="@((string)(context as PredicateModel).Value)" DataSource="@TransactionTypeValues" TValue="string" TItem="string" ShowClearButton="true">
                            <DropDownListEvents ValueChange="@HandleChangeTransactionTypeFilter" TValue="string"></DropDownListEvents>
                            <DropDownListFieldSettings Value="string" Text="string"></DropDownListFieldSettings>
                        </SfDropDownList>
                    </FilterTemplate>
                </GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.ActivityType) HeaderText="Activity Type" Width="175px">
                    <FilterTemplate>
                        <SfDropDownList Placeholder="Activity Type" ID="ActivityType"
                                        Value="@((string)(context as PredicateModel).Value)" DataSource="@ActivityTypeValues" TValue="string" TItem="string" ShowClearButton="true">
                            <DropDownListEvents ValueChange="@HandleChangeActivityTypeFilter" TValue="string"></DropDownListEvents>
                            <DropDownListFieldSettings Value="string" Text="string"></DropDownListFieldSettings>
                        </SfDropDownList>
                    </FilterTemplate>
                </GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.CreditTransactionQuantity) HeaderText="Credit Qty" Format="n0" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="100"></GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.DebitTransactionQuantity) HeaderText="Debit Qty" Format="n0" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="100"></GridColumn>
                <GridColumn Field=@nameof(TransactionActivity.Status) HeaderText="Status" Width="150px">
                    <FilterTemplate>
                        <SfDropDownList Placeholder="Status Type" ID="Status"
                                        Value="@((string)(context as PredicateModel).Value)" DataSource="@StatusTypeValues" TValue="string" TItem="string" ShowClearButton="true">
                            <DropDownListEvents ValueChange="@HandleChangeStatusTypeFilter" TValue="string"></DropDownListEvents>
                            <DropDownListFieldSettings Value="string" Text="string"></DropDownListFieldSettings>
                        </SfDropDownList>
                    </FilterTemplate>
                </GridColumn>

            </GridColumns>
        </SfGrid>


I am getting the error form the three FilterTemplates what have SfDropDownList components that reference code-behind methods to handle their ValueChange events.

Here is the HandleChangeStatusTypeFilter method, the other two methods that are getting the error are nearly identical;

        protected void HandleChangeStatusTypeFilter(ChangeEventArgs<string> args)
        {
            var fieldsToClear = new List<string>
            {
                "Status",
            };

            if (args.Value == null)
            {
                Grid.ClearFiltering(fieldsToClear);
            }
            else
            {
                Grid.FilterByColumn("Status", "equal", args.Value, null, true);
            }
        }


What am I missing?









5 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team July 22, 2020 02:02 PM UTC

Hi David, 

We suspect that you may be facing namespace conflicts for the ChangeEventArgs class in your application. So we suggest you to ensure to use as like the below highlighted code to overcome the problem you are facing, 

 
protected void HandleChangeStatusTypeFilter(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args) 
{ 
    var fieldsToClear = new List<string> 
        { 
            "Status", 
        }; 
 
    if (args.Value == null) 
    { 
        Grid.ClearFiltering(fieldsToClear); 
    } 
    else 
    { 
        Grid.FilterByColumn("Status""equal", args.Value, nulltrue); 
    } 
} 


And if you are still facing difficulties, then kindly share with us the screenshot showing the reported problem in your VS application. 

Regards, 
Renjith Singh Rajendran 


Marked as answer

DA David Adler July 22, 2020 02:37 PM UTC

Perfect. That was the issue. Thanks 


RS Renjith Singh Rajendran Syncfusion Team July 23, 2020 12:25 PM UTC

Hi David, 
 
Thanks for your update. 
 
We are glad to hear that the suggestion helped you in resolving the problem you are facing. 
 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith Singh Rajendran 



MW Muhammad Waleed February 26, 2024 06:46 AM UTC

on my group change all data vipes all maybe becausse of my filtering code which is dynamic .How Shall i handle grouping and filtering together by code

@page "/EmployeeManagement"

@using Syncfusion.Blazor.Grids

@rendermode InteractiveServer

<style>

    .e-grid .e-gridheader .e-icons:not(.e-icon-hide):not(.e-check):not(.e-stop):not(.e-icon-reorderuparrow):not(.e-icon-reorderdownarrow){

        color:transparent!important;

    }

</style>


<h3>EmployeeManagement</h3>

<div style="max-width:900px">

    <SfGrid TValue="EmployeeModel" AllowGrouping="true" DataSource="@employeeData" AllowSorting="true" AllowPaging="true" AllowFiltering="true" Toolbar="@toolbar" AutoGenerateColumns="true">

        <GridPageSettings PageSize="8"></GridPageSettings>

        <GridGroupSettings Columns="@Initialgroup" ShowDropArea="true" ShowToggleButton="true" ShowGroupedColumn="true" ShowUngroupButton="true" />


        <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu" Columns="@FilterableGridFilterColumns"></GridFilterSettings>

        <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>

    </SfGrid>

</div>


@code {

    public List<GridFilterColumn> FilterableGridFilterColumns { get; set; } = new List<GridFilterColumn>();



    private List<EmployeeModel>? employeeData = null;

    private List<object> toolbar = new List<object> { "Add", "Edit", "Delete", "Update", "Cancel", "Search" };

    public string[] Initialgroup = (new string[] { "Gender" });



    protected override void OnInitialized()

    {

        GenerateEmployeeData();


        var filterableColumns = new List<string> { "FirstName", "LastName" };


        foreach (var columnName in filterableColumns)

        {

            var column = new GridFilterColumn { Field = columnName };

            FilterableGridFilterColumns.Add(column);

        }

    }


    private void GenerateEmployeeData()

    {

        employeeData = new List<EmployeeModel>();


        for (int i = 1; i <= 10; i++)

        {

            EmployeeModel emp = new EmployeeModel

                {

                    Id = i,

                    FirstName = "FirstName" + i,

                    LastName = "LastName" + i,

                    JobTitle = "JobTitle" + i,

                    Gender = i % 2 == 0 ? "Male" : "Female",

                    DateOfBirth = DateTime.Now.AddYears(-20).AddMonths(i),

                    ReportToEmpId = i > 3 ? 1 : (int?)null

                };


            employeeData.Add(emp);

        }

    }


    public class EmployeeModel

    {

        public int Id { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string JobTitle { get; set; }

        public string Gender { get; set; }

        public DateTime DateOfBirth { get; set; }

        public int? ReportToEmpId { get; set; }

    }

}




MS Monisha Saravanan Syncfusion Team February 27, 2024 11:54 AM UTC


Hi Muhammad Waleed,


We have created a separate forum for your query. Kindly check the mentioned thread for further follow-ups.


Loader.
Up arrow icon