Issue with OperatorsModel - is set to the wrong filter on selected

With this code I specified Operators models for FirstName (equal & not equal), Country (equal) & Decision (equal).

In case when I want to use a values for Decision as a dropdown values operator is set to 'startsWith' even it is blank.

Image_4578_1736161849927

Image_5913_1736162110532

The operator should be set to 'equal' as it is the only valid one in DecisionsOperators 

How to set the operator to the specified one and how to select default value (1st item on the list).


Please see my code below: 

@page "/test"
@using Syncfusion.Blazor.QueryBuilder
<div class="page-content">
    <div class="row">
        <div class="pb-2 pt-2">
            <SfQueryBuilder TValue="EmployeeDetails">
                <QueryBuilderColumns>
                    <QueryBuilderColumn Field="FirstName" Label="First Name" Type="Syncfusion.Blazor.QueryBuilder.ColumnType.String" Operators="FirstNameOperators"></QueryBuilderColumn>
                    <QueryBuilderColumn Field="Country" Label="Country" Type="Syncfusion.Blazor.QueryBuilder.ColumnType.String" Operators="CountryOperators"></QueryBuilderColumn>
                    <QueryBuilderColumn Field="City" Label="City" Type="Syncfusion.Blazor.QueryBuilder.ColumnType.String"></QueryBuilderColumn>
                    @*Decisions*@
                    <QueryBuilderColumn Field="Decision" Label="Overall Decision" Type="Syncfusion.Blazor.QueryBuilder.ColumnType.String" Operators="@DecisionsOperators">
                        <QueryBuilderTemplates>
                            <ValueTemplate>


                                @if (context is RuleModel rule)
                                {
                                    <SfDropDownList TValue="string" TItem="string" DataSource="@Decisions" Value="@(rule.Value as string)">
                                        <DropDownListFieldSettings Text="Name" Value="Value"></DropDownListFieldSettings>
                                        <DropDownListEvents TItem="string" TValue="string" ValueChange="e => OnDecisionChange(e, context)"></DropDownListEvents>
                                    </SfDropDownList>
                                }
                            </ValueTemplate>
                        </QueryBuilderTemplates>
                    </QueryBuilderColumn>
                </QueryBuilderColumns>
            </SfQueryBuilder>
        </div>
    </div>
</div>


@code {
    public class EmployeeDetails
    {
        public string FirstName { get; set; }
        public string Country { get; set; }
        public string City { get; set; }
        public string Decision { get; set; }
    }
    private List<Syncfusion.Blazor.QueryBuilder.OperatorsModel> FirstNameOperators = new()
    {
        new Syncfusion.Blazor.QueryBuilder.OperatorsModel {Text="Equal", Value ="equal"},
        new Syncfusion.Blazor.QueryBuilder.OperatorsModel {Text="Not Equal", Value ="notequal"},
    };
    private List<Syncfusion.Blazor.QueryBuilder.OperatorsModel> CountryOperators = new()
    {
        new Syncfusion.Blazor.QueryBuilder.OperatorsModel {Text="Equal", Value ="equal"},
    };
    private List<Syncfusion.Blazor.QueryBuilder.OperatorsModel> DecisionsOperators = new()
    {
        new Syncfusion.Blazor.QueryBuilder.OperatorsModel {Text="Equal", Value ="equal"},
    };
    private List<string> Decisions = new()
    {
        "Pending",
        "Fail",
        "Pass",
        "NotSet"
    };
    private void OnDecisionChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, string> args, RuleModel rule)
    {
        rule.Value = args.Value;
    }
}

2 Replies 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team January 7, 2025 07:21 AM UTC

Hi Pawel,


We have validated your reported query, and for more clarification, we have the DefaultSelectedOperator property of the query builder has an auto. If it is auto, then we have to render the default operator values for columns based on column type. In your case, you have customized the operator values, and the default select operator for string type is the startswith value, but the startswith value is not present in your custom operator values. Due to this reason, the operator dropdown renders with empty values in the UI and passes the startswith in the rule model.


For now, to resolve this issue, kindly se the DefaultSelectedOperator as EQUAL in your sample.


<SfQueryBuilder TValue="EmployeeDetails" DefaultSelectedOperator="QueryBuilderOperatorType.Equal">


Additional we have confirmed the issue as “Custom operators not render properly with DefaultSelectedOperator as auto in query builder." and logged a defect report. We will include the fix for this issue in the upcoming weekly release scheduled for the 21st of January 2025.


Feedback link: https://www.syncfusion.com/feedback/64472/custom-operators-not-render-properly-with-defaultselectedoperator-as-auto-in-query


You will be informed regarding this once the fix is published.

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”

Regards,

YuvanShankar A


Marked as answer

YA YuvanShankar Arunagiri Syncfusion Team January 14, 2025 06:44 AM UTC

Hi Pawel,


We are glad to announce that our weekly patch release (28.1.39) has been rolled out. We have included the fix for “Custom operators not render properly with DefaultSelectedOperator as auto in query builder” in this release. So, we suggest you upgrade our Syncfusion packages to our latest version to resolve this issue on your end (28.1.39).


Root cause: Not considering the custom operators values while setting the operator values from rule with DefaultSelectedOperator as auto.


Package link: https://www.nuget.org/packages/Syncfusion.Blazor.QueryBuilder


Please let us know if you need any further assistance on this.


Regards,

YuvanShankar A


Loader.
Up arrow icon