menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfQueryBuilder<TValue> - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfQueryBuilder<TValue>

    The Query Builder is a graphical user interface component that allows users to create and edit filter conditions for large datasets.

    Inheritance
    System.Object
    SfBaseComponent
    SfDataBoundComponent
    SfQueryBuilder<TValue>
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.GetEffectivePlatform()
    SfBaseComponent.GetMainComponentPlatform()
    SfBaseComponent.IsMainLicenseComponent()
    SfBaseComponent.LicenseContext
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    SfBaseComponent.ValidateLicense()
    SfDataBoundComponent.DataManager
    SfDataBoundComponent.MainParent
    SfDataBoundComponent.SetDataManager<T>(Object)
    Namespace: Syncfusion.Blazor.QueryBuilder
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfQueryBuilder<TValue> : SfDataBoundComponent, IQueryBuilder
    Type Parameters
    Name Description
    TValue

    Specifies the data type of the items in the data source.

    Remarks

    The component provides an intuitive way to build complex queries with multiple conditions, groups, and operators. It supports data binding to various sources and can generate SQL-like queries or predicates for filtering.

    Examples

    A simple Query Builder component.

    <SfQueryBuilder TValue="EmployeeData" @ref="QueryBuilderObj">
        <QueryBuilderColumns>
            <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
            <QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
            <QueryBuilderColumn Field="City" Label="City" Type="ColumnType.String"></QueryBuilderColumn>
        </QueryBuilderColumns>
    </SfQueryBuilder>
    

    @code { SfQueryBuilder<EmployeeData> QueryBuilderObj;

    public class EmployeeData
    {
        public int EmployeeID { get; set; }
        public string FirstName { get; set; }
        public string City { get; set; }
    }
    

    }

    A simple Query Builder component.

    @using Syncfusion.Blazor.QueryBuilder
    <SfQueryBuilder TValue="EmployeeDetails">
        <QueryBuilderColumns>
            <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
            <QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
            <QueryBuilderColumn Field="HireDate" Label="Hire Date" Type="ColumnType.Date"></QueryBuilderColumn>
        </QueryBuilderColumns>
    </SfQueryBuilder>
    public class EmployeeDetails
    {
        public int EmployeeID { get; set; }
        public string FirstName { get; set; }
        public DateTime HireDate { get; set; }
    }

    A simple Query Builder component.

    <SfQueryBuilder TValue="EmployeeDetails" CssClass="e-custom-filter">
        <QueryBuilderColumns>
            <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
            <QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
            <QueryBuilderColumn Field="HireDate" Label="Hire Date" Type="ColumnType.Date" Format="M/d/yyyy"></QueryBuilderColumn>
        </QueryBuilderColumns>
    </SfQueryBuilder>
    
    public class EmployeeDetails
    {
        public int EmployeeID { get; set; }
        public string FirstName { get; set; }
        public DateTime HireDate { get; set; }
    }

    Constructors

    SfQueryBuilder()

    Declaration
    public SfQueryBuilder()

    Properties

    AllowDragAndDrop

    Gets or sets a value indicating whether drag-and-drop functionality is enabled for reordering rules and groups.

    Declaration
    public bool AllowDragAndDrop { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable drag-and-drop; otherwise, false. The default value is false.

    Remarks

    When this property is set to true, a drag handle is displayed next to each rule and group, allowing users to reorder them.

    AllowValidation

    Gets or sets a value indicating whether validation is enabled for the filter rules.

    Declaration
    public bool AllowValidation { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable validation; otherwise, false. The default value is false.

    Remarks

    When enabled, the Query Builder validates the filter conditions to ensure they are complete and valid before applying them.

    ChildContent

    Gets or sets the content to be rendered inside the Query Builder component, which typically includes column definitions.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.RenderFragment

    A Microsoft.AspNetCore.Components.RenderFragment representing the child content, such as QueryBuilderColumns.

    Remarks

    This property is used to define the columns that will be available for building filter conditions.

    ColumnTemplate

    Gets or sets the template for rendering columns in the Query Builder.

    Declaration
    public RenderFragment<RuleModel> ColumnTemplate { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.RenderFragment<RuleModel>

    A Microsoft.AspNetCore.Components.RenderFragment<> of type RuleModel that specifies the template for columns.

    Remarks

    This template allows for custom rendering of the columns in the user interface.

    CssClass

    Gets or sets a string of CSS classes to be applied to the SfQueryBuilder<TValue> component.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the CSS classes. The default value is string.Empty.

    Remarks

    This property is used to customize the appearance of the Query Builder.

    DataSource

    Gets or sets the data source that the SfQueryBuilder<TValue> operates on.

    Declaration
    public IEnumerable<TValue> DataSource { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<TValue>

    An System.Collections.Generic.IEnumerable<> collection that serves as the data source for the component.

    Remarks

    The Query Builder uses this data source to populate fields and validate conditions.

    DefaultSelectedField

    Gets or sets the field that is selected by default when adding a new rule or group.

    Declaration
    public string DefaultSelectedField { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the field name. The default value is an empty string.

    Remarks

    The specified field will be pre-selected in the field dropdown, and the operator and value controls will be rendered accordingly.

    DefaultSelectedOperator

    Gets or sets the operator that is selected by default when adding a new rule or changing a field.

    Declaration
    public QueryBuilderOperatorType DefaultSelectedOperator { get; set; }
    Property Value
    Type Description
    QueryBuilderOperatorType

    A QueryBuilderOperatorType enum value. The default is automatically determined based on the field's data type.

    Remarks

    The operator dropdown will be pre-selected with this value, and the corresponding value control will be rendered.

    DisplayMode

    Gets or sets the display mode for the Query Builder, which determines the layout of rules and groups.

    Declaration
    public DisplayMode DisplayMode { get; set; }
    Property Value
    Type Description
    DisplayMode

    One of the DisplayMode enumeration values. The default value is DisplayMode.Horizontal.

    Remarks

    The display mode can be set to either Horizontal or Vertical to control the alignment of the filter conditions.

    EnableIndividualConditions

    Gets or sets a value indicating whether rules and groups have their own individual connectors.

    Declaration
    public bool EnableIndividualConditions { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable individual connectors; otherwise, false. The default value is false.

    Remarks

    When enabled, each rule and group can be connected with a different logical operator (e.g., AND/OR). When disabled, a single connector is shared among all items at the same level.

    EnableNotCondition

    Gets or sets a value indicating whether the "NOT" condition can be applied to groups.

    Declaration
    public bool EnableNotCondition { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable the "NOT" condition for groups; otherwise, false. The default value is false.

    Remarks

    When enabled, users can invert the logic of a group of conditions.

    EnablePersistence

    Gets or sets a value indicating whether the component's state should be persisted across page reloads.

    Declaration
    public bool EnablePersistence { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable state persistence; otherwise, false. The default value is false.

    Remarks

    When enabled, the current filter conditions are saved and restored when the user navigates back to the page.

    EnableRtl

    Gets or sets a value indicating whether right-to-left (RTL) rendering is enabled for the component.

    Declaration
    public bool EnableRtl { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable RTL mode; otherwise, false. The default value is false.

    Remarks

    This property is useful for adapting the component to languages that are read from right to left.

    Height

    Gets or sets the height of the SfQueryBuilder<TValue> component.

    Declaration
    public string Height { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the height (e.g., "300px"). The default value is "auto".

    Remarks

    This property allows you to control the vertical dimension of the Query Builder.

    ID

    Gets or sets the unique identifier for the SfQueryBuilder<TValue> component.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    A string that represents the ID of the Query Builder. The default value is an automatically generated unique identifier.

    Remarks

    The ID is used to uniquely identify the component in the DOM.

    ImmediateModeDelay

    Gets or sets the time delay in milliseconds before a rule change triggers an update.

    Declaration
    public double ImmediateModeDelay { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the delay in milliseconds. The default value is 0.

    Remarks

    This property is useful for improving performance by delaying the update of the query until the user has finished making changes.

    MatchCase

    Gets or sets a value indicating whether string comparisons are case-sensitive.

    Declaration
    public bool MatchCase { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to perform case-sensitive filtering; otherwise, false. The default value is false.

    Remarks

    This property determines how string values are compared in the filter conditions.

    MaxGroupCount

    Gets or sets the maximum number of nested groups allowed in the Query Builder.

    Declaration
    public int MaxGroupCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the maximum number of groups. The default value is 5.

    Remarks

    This property helps to control the complexity of the filter queries that can be created.

    Readonly

    Gets or sets a value indicating whether the SfQueryBuilder<TValue> is in a read-only state.

    Declaration
    public bool Readonly { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the component is read-only; otherwise, false. The default value is false.

    Remarks

    When set to true, users cannot add, edit, or delete filter conditions.

    Separator

    Gets or sets the separator used for parsing complex data-bound fields.

    Declaration
    public string Separator { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the separator character.

    Remarks

    This is used when binding to nested properties of a complex object.

    SortDirection

    Gets or sets the sort direction for the field names in the dropdown list.

    Declaration
    public SortDirection SortDirection { get; set; }
    Property Value
    Type Description
    SortDirection

    One of the SortDirection enumeration values. The default value is SortDirection.Default.

    Remarks

    The fields can be sorted in ascending, descending, or default order.

    SummaryView

    Gets or sets a value indicating whether a summary view of the filter query is displayed.

    Declaration
    public bool SummaryView { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to display the summary view; otherwise, false. The default value is false.

    Remarks

    The summary view provides a human-readable representation of the current filter conditions.

    UniqueFilterMode

    Gets or sets a value that restricts the creation of multiple filter conditions for the same field.

    Declaration
    public UniqueFilterMode UniqueFilterMode { get; set; }
    Property Value
    Type Description
    UniqueFilterMode

    One of the UniqueFilterMode enumeration values. The default value is None.

    Remarks

    This property can prevent duplicate filter conditions for a field within a group or across all groups.

    Width

    Gets or sets the width of the SfQueryBuilder<TValue> component.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the width (e.g., "100%"). The default value is "auto".

    Remarks

    This property allows you to control the horizontal dimension of the Query Builder.

    Methods

    AddGroup(RuleModel, String)

    Adds a single group or multiple groups, which contains a collection of rules, to the query builder.

    Declaration
    public void AddGroup(RuleModel group, string groupID)
    Parameters
    Type Name Description
    RuleModel group

    Specifies the group to be added.

    System.String groupID

    Specifies the group ID to which the group should be added.

    Remarks

    This method allows for the dynamic addition of rule groups to the Query Builder.

    Examples

    The following code example demonstrates how to add a group to the Query Builder.

    <SfButton Content="Add Group" @onclick="AddGroup"></SfButton>
    <SfQueryBuilder @ref="QueryBuilderObj" TValue="Employee">
        <QueryBuilderColumns>
            <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
            <QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
        </QueryBuilderColumns>
    </SfQueryBuilder>
    @code {
        SfQueryBuilder<Employee> QueryBuilderObj;
        private void AddGroup()
        {
            var group = new RuleModel { Rules = new List<RuleModel>(), Condition = "and" };
            QueryBuilderObj.AddGroup(group, "group0");
        }
        public class Employee
        {
            public int EmployeeID { get; set; }
            public string FirstName { get; set; }
        }
    }

    AddRule(RuleModel, String, Boolean)

    Adds a rule to the specified group in the Query Builder.

    Declaration
    public void AddRule(RuleModel rule, string groupID, bool isGroupRule = false)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel to be added.

    System.String groupID

    The ID of the group where the rule will be added.

    System.Boolean isGroupRule

    If set to true, the rule is added as a new group. The default value is false.

    Remarks

    This method allows for the dynamic addition of rules to a specified group. If isGroupRule is true, the rule is encapsulated within a new group, allowing for nested conditions. Otherwise, the rule is added directly to the bottom of the specified group.

    Examples
    <SfButton Content="Add Rule" @onclick="AddRule"></SfButton>
    <SfQueryBuilder TValue="Employee" @ref="QueryBuilderObj">
       <QueryBuilderColumns>
         <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
         <QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
         <QueryBuilderColumn Field="LastName" Label="Last Name" Type="ColumnType.String"></QueryBuilderColumn>
         <QueryBuilderColumn Field="HireDate" Label="Hire Date" Type="ColumnType.Date">
    </QueryBuilderColumn>
         <QueryBuilderColumn Field="Country" Label="Country" Type="ColumnType.String"></QueryBuilderColumn>
       </QueryBuilderColumns>
    </SfQueryBuilder>
    @code
    {
        SfQueryBuilder<Employee> QueryBuilderObj;
        public class Employee
        {
            public int EmployeeID { get; set; }
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public DateTime HireDate { get; set; }
            public string Country { get; set; }
        }
        private void AddRule(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
        {
            QueryBuilderObj.AddRule(new RuleModel(), "group0");
        }
    }

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    CloneGroup(String, Int32)

    Clones a group and its rules, and inserts it into a parent group at the specified index.

    Declaration
    public void CloneGroup(string groupID, int index = -1)
    Parameters
    Type Name Description
    System.String groupID

    The ID of the group to be cloned.

    System.Int32 index

    The index within the parent group where the cloned group will be inserted. If -1, the group is added to the end. The default value is -1.

    Remarks

    This method creates a deep copy of an existing group, including all its rules and subgroups.

    CloneRule(String, Int32)

    Clones a rule and inserts it into a group at the specified index.

    Declaration
    public void CloneRule(string ruleID, int index = -1)
    Parameters
    Type Name Description
    System.String ruleID

    The ID of the rule to be cloned.

    System.Int32 index

    The index within the parent group where the cloned rule will be inserted. If -1, the rule is added to the end. The default value is -1.

    Remarks

    This method creates a copy of an existing rule and adds it to the same group.

    DeleteGroup(String)

    Deletes a group, including its nested rules and groups, based on the specified group ID.

    Declaration
    public void DeleteGroup(string groupId)
    Parameters
    Type Name Description
    System.String groupId

    The ID of the group to be deleted.

    Remarks

    This method finds the target group using the provided groupId and removes it from the Query Builder's rule set. All rules and subgroups contained within the deleted group are also removed.

    Examples

    In the following example, a group is deleted from the Query Builder.

    <SfButton Content="Delete Group" @onclick="@(() => QueryBuilderObj.DeleteGroup("group1"))"></SfButton>
    <SfQueryBuilder @ref="QueryBuilderObj" TValue="Employee">
       <QueryBuilderColumns>
           <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
       </QueryBuilderColumns>
       <QueryBuilderRules>
            <QueryBuilderRule Condition="and" Rules="
            new List<RuleModel> {
                new RuleModel { Field = "EmployeeID", Label="Employee ID", Operator="equal", Type="number", Value=1001 }
            }"></QueryBuilderRule>
       </QueryBuilderRules>
    </SfQueryBuilder>
    @code {
        SfQueryBuilder<Employee> QueryBuilderObj;
        public class Employee
        {
            public int EmployeeID { get; set; }
        }
    }

    DeleteRule(String)

    Deletes a rule based on the specified rule ID.

    Declaration
    public void DeleteRule(string ruleId)
    Parameters
    Type Name Description
    System.String ruleId

    The ID of the rule to be deleted.

    Remarks

    This method removes the rule corresponding to the given ruleId from the Query Builder.

    Examples

    The following code snippet demonstrates how to delete a rule from the Query Builder.

    <SfButton Content="Delete Rule" @onclick="@(() => QueryBuilderObj.DeleteRule("querybuilder_group0_rule0"))"></SfButton>
    <SfQueryBuilder @ref="QueryBuilderObj" TValue="Employee">
       <QueryBuilderColumns>
           <QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
       </QueryBuilderColumns>
       <QueryBuilderRules>
            <QueryBuilderRule Condition="and" Rules="
            new List<RuleModel> {
                new RuleModel { Field = "EmployeeID", Label="Employee ID", Operator="equal", Type="number", Value=1001 }
            }"></QueryBuilderRule>
       </QueryBuilderRules>
    </SfQueryBuilder>
    @code {
        SfQueryBuilder<Employee> QueryBuilderObj;
        public class Employee
        {
            public int EmployeeID { get; set; }
        }
    }

    Dispose(Boolean)

    Releases the unmanaged resources used by the SfQueryBuilder<TValue> and optionally releases the managed resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Overrides
    SfBaseComponent.Dispose(Boolean)
    Remarks

    This method is called by the public Dispose() method and the finalizer. When disposing is true, this method releases all resources held by any managed objects that this SfQueryBuilder<TValue> references.

    GetColumn(String)

    Gets the column definition for a specified field name.

    Declaration
    public ColumnsModel GetColumn(string field)
    Parameters
    Type Name Description
    System.String field

    The field name for which to retrieve the column definition.

    Returns
    Type Description
    Syncfusion.Blazor.QueryBuilder.Internal.ColumnsModel

    A Syncfusion.Blazor.QueryBuilder.Internal.ColumnsModel object that represents the column definition. If the field is not found, an empty model is returned where properties like Syncfusion.Blazor.QueryBuilder.Internal.ColumnsModel.Field will be null.

    Remarks

    This method searches through the component's column collection to find a column that matches the provided field name. It performs a recursive search in case of complex column configurations with nested columns.

    Examples

    This example demonstrates how to retrieve a column and access its properties.

    var column = QueryBuilder.GetColumn("EmployeeID");
    if (column?.Field != null)
    {
        Console.WriteLine($"The label for the column is: {column.Label}");
    }

    GetDataManagerQuery(RuleModel)

    Gets the query for the DataManager.

    Declaration
    public Query GetDataManagerQuery(RuleModel rule = null)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel from which to generate the query. If null, the current rules of the Query Builder are used.

    Returns
    Type Description
    Query

    A Query object that can be used with a DataManager.

    Remarks

    This method translates the Query Builder's rules into a Query object, which is compatible with the Syncfusion DataManager for data filtering operations.

    GetFilteredRecords()

    Gets the locally filtered records based on the rules defined in the Query Builder.

    Declaration
    public IEnumerable<TValue> GetFilteredRecords()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<TValue>

    An System.Collections.Generic.IEnumerable<> collection of records that match the defined rules.

    Remarks

    This method applies the current filter rules to the local DataSource. It uses the PerformFiltering(IEnumerable, List<WhereFilter>, String) method to process the data synchronously. If the Query Builder is bound to a remote data source using a DataManager, use the GetFilteredRecordsAsync() method instead.

    Exceptions
    Type Condition
    System.NullReferenceException

    Thrown if an error occurs while accessing the data source.

    GetFilteredRecordsAsync()

    Asynchronously gets the filtered records based on the rules defined in the Query Builder.

    Declaration
    public Task<IEnumerable<TValue>> GetFilteredRecordsAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TValue>>

    A System.Threading.Tasks.Task<> that represents the asynchronous operation. The task result contains an System.Collections.Generic.IEnumerable<> collection of records that match the defined rules.

    Remarks

    This method is suitable for both local and remote data sources. If a DataManager is configured, it fetches and filters remote data. Otherwise, it filters the local DataSource.

    Exceptions
    Type Condition
    System.NullReferenceException

    Thrown if an error occurs while accessing the data source.

    GetGroup()

    Gets the root group containing all the rules and conditions.

    Declaration
    public RuleModel GetGroup()
    Returns
    Type Description
    RuleModel

    A RuleModel object representing the entire set of valid rules.

    Remarks

    This method is an alias for GetValidRules(). It returns a hierarchical structure of rules and groups.

    GetMongoQuery(RuleModel)

    Gets a MongoDB query string from the Query Builder based on the specified rule model.

    Declaration
    public string GetMongoQuery(RuleModel rule)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel used to generate the MongoDB query.

    Returns
    Type Description
    System.String

    A System.String which represents the MongoDB query.

    Remarks

    The value returned by this method can be used to filter records from a MongoDB database, for instance with BsonDocument.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown if the rule is null.

    GetNamedParameterSql(RuleModel)

    Gets a named parameterized SQL query from the Query Builder based on the rule model.

    Declaration
    public NamedParameterSql GetNamedParameterSql(RuleModel rule = null)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel to be used for generating the named parameterized SQL query. If null, the current valid rules of the Query Builder are used.

    Returns
    Type Description
    NamedParameterSql

    A NamedParameterSql object which represents the named parameterized SQL query.

    Remarks

    The value returned by this method can be used to filter records from SQL-based databases using named parameters.

    GetOperators(String)

    Gets the list of available operators for a specific field.

    Declaration
    public List<OperatorsModel> GetOperators(string field)
    Parameters
    Type Name Description
    System.String field

    The field name for which to retrieve the operators.

    Returns
    Type Description
    System.Collections.Generic.List<OperatorsModel>

    A System.Collections.Generic.List<> of OperatorsModel containing the operators associated with the specified field. Returns null if the field is not found.

    Remarks

    This method allows you to dynamically retrieve the operators configured for a given column in the Query Builder.

    GetParameterSql(RuleModel)

    Gets a parameterized SQL query from the Query Builder based on the provided rule model.

    Declaration
    public ParameterSql GetParameterSql(RuleModel rule = null)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel to be used for generating the parameterized SQL query. If null, the current valid rules of the Query Builder are used.

    Returns
    Type Description
    ParameterSql

    A ParameterSql object which represents the parameterized SQL query.

    Remarks

    The ParameterSql object contains a parameterized SQL string and a dictionary of parameters, which helps prevent SQL injection attacks. This query can be used to filter records from SQL-based databases.

    GetPredicate(RuleModel)

    Gets a WhereFilter predicate from the rules.

    Declaration
    public WhereFilter GetPredicate(RuleModel rule = null)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel from which to generate the predicate. If null, the current valid rules of the Query Builder are used.

    Returns
    Type Description
    WhereFilter

    A WhereFilter object that can be used for data filtering operations.

    Remarks

    This method translates the Query Builder rules into a WhereFilter object, which is used internally by the Syncfusion DataManager for filtering. This is useful for creating complex, nested filter conditions.

    GetRule(String)

    Gets the RuleModel of a rule or group based on its ID.

    Declaration
    public RuleModel GetRule(string ID)
    Parameters
    Type Name Description
    System.String ID

    The ID of the rule or group to retrieve.

    Returns
    Type Description
    RuleModel

    The RuleModel corresponding to the provided ID.

    Remarks

    This method can retrieve the model for an individual rule or an entire group. If the ID corresponds to the root group, it returns the entire rule set.

    GetRules()

    Gets the current rules from the Query Builder.

    Declaration
    public RuleModel GetRules()
    Returns
    Type Description
    RuleModel

    A RuleModel representing the current rules and conditions.

    Remarks

    This method retrieves the complete set of rules currently active in the Query Builder, including all groups and conditions.

    GetRulesFromSql(String)

    Converts a SQL query string into a RuleModel.

    Declaration
    public RuleModel GetRulesFromSql(string sqlString = null)
    Parameters
    Type Name Description
    System.String sqlString

    The SQL query string to be converted. If null, the current rules are converted into SQL and then back into a RuleModel.

    Returns
    Type Description
    RuleModel

    A RuleModel representing the rules parsed from the SQL string.

    Remarks

    This method parses a SQL WHERE clause and converts it into a structured RuleModel that can be loaded into the Query Builder.

    GetSqlFromRules(RuleModel, Boolean)

    Converts a RuleModel into a SQL query string.

    Declaration
    public string GetSqlFromRules(RuleModel rule = null, bool allowEscape = false)
    Parameters
    Type Name Description
    RuleModel rule

    The RuleModel to convert. If null, the current valid rules of the Query Builder are used.

    System.Boolean allowEscape

    If set to true, special characters in the query are escaped. The default value is false.

    Returns
    Type Description
    System.String

    A System.String representing the SQL WHERE clause generated from the rules.

    Remarks

    This method generates a SQL query string from the current or specified rules, which can be used to query a database.

    GetValidRules()

    Gets the collection of valid rules from the Query Builder.

    Declaration
    public RuleModel GetValidRules()
    Returns
    Type Description
    RuleModel

    A RuleModel representing the set of valid rules.

    Remarks

    This method filters out invalid or incomplete rules and returns only the valid ones that can be used for querying.

    LockGroup(String, Boolean)

    Locks or unlocks a specific group in the Query Builder.

    Declaration
    public void LockGroup(string groupID, bool isLocked = true)
    Parameters
    Type Name Description
    System.String groupID

    The ID of the group to lock or unlock.

    System.Boolean isLocked

    Set to true to lock the group, or false to unlock it. The default value is true.

    Remarks

    A locked group and all its contents (rules and subgroups) cannot be modified or deleted by the user through the UI.

    LockRule(String, Boolean)

    Locks or unlocks a specific rule in the Query Builder.

    Declaration
    public void LockRule(string ruleID, bool isLocked = true)
    Parameters
    Type Name Description
    System.String ruleID

    The ID of the rule to lock or unlock.

    System.Boolean isLocked

    Set to true to lock the rule, or false to unlock it. The default value is true.

    Remarks

    A locked rule cannot be modified or deleted by the user through the UI.

    OnAfterRenderAsync(Boolean)

    Method invoked after the component has rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    A boolean value that indicates if this is the first time the component has been rendered.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous render operation.

    Overrides
    SfDataBoundComponent.OnAfterRenderAsync(Boolean)
    Remarks

    This method is used for performing operations after the component's markup is in the Document Object Model (DOM). On the initial render, it sets up data binding, initializes columns, and creates the default rule set. On subsequent renders, it responds to property changes.

    OnInitializedAsync()

    Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous initialization operation.

    Overrides
    SfDataBoundComponent.OnInitializedAsync()
    Remarks

    This method is called once during the component's lifecycle. It is used to initialize the component's state, set up required modules like Syncfusion.Blazor.QueryBuilder.SfQueryBuilder`1.PredicateModule and Syncfusion.Blazor.QueryBuilder.SfQueryBuilder`1.SqlModule, and prepare the necessary operators for building queries.

    OnParametersSetAsync()

    Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous operation.

    Overrides
    SfDataBoundComponent.OnParametersSetAsync()
    Remarks

    This method is called before OnInitializedAsync() on the first render and may be called multiple times throughout the component's lifecycle if parameters change. It handles updates to properties such as Syncfusion.Blazor.QueryBuilder.SfQueryBuilder`1.QBRule and EnableRtl and resets the rules if needed.

    Reset()

    Resets the Query Builder to its initial state, clearing all rules and groups.

    Declaration
    public void Reset()
    Remarks

    This method removes all rules and groups, restoring the Query Builder to its default configuration. If EnablePersistence is true, the reset state will also be persisted.

    SetMongoQuery(String)

    Sets the rules in the Query Builder from a MongoDB query string.

    Declaration
    public void SetMongoQuery(string mongoQuery)
    Parameters
    Type Name Description
    System.String mongoQuery

    Specifies the MongoDB query to be loaded into the Query Builder.

    Remarks

    This method parses the MongoDB query string and configures the Query Builder's rules accordingly.

    SetNamedParameterSql(NamedParameterSql)

    Sets the rules in the Query Builder from a named parameterized SQL query.

    Declaration
    public void SetNamedParameterSql(NamedParameterSql sqlQuery)
    Parameters
    Type Name Description
    NamedParameterSql sqlQuery

    The NamedParameterSql object to be loaded into the Query Builder.

    Remarks

    This method configures the Query Builder's rules based on the provided named parameterized SQL query.

    SetParameterSql(ParameterSql)

    Sets the rules in the Query Builder from a parameterized SQL query.

    Declaration
    public void SetParameterSql(ParameterSql sqlQuery)
    Parameters
    Type Name Description
    ParameterSql sqlQuery

    The ParameterSql object to be loaded into the Query Builder.

    Remarks

    This method populates the Query Builder with rules derived from the provided parameterized SQL query.

    SetRules(List<RuleModel>, String, Nullable<Boolean>, Boolean)

    Replaces the current rules with a new set of rules.

    Declaration
    public void SetRules(List<RuleModel> rule, string condition = "and", Nullable<bool> not, bool isLocked = false)
    Parameters
    Type Name Description
    System.Collections.Generic.List<RuleModel> rule

    A System.Collections.Generic.List<> of RuleModel objects to be set.

    System.String condition

    The logical condition (and or or) to apply to the root group. The default is and.

    System.Nullable<System.Boolean> not

    If set to true, applies a NOT condition to the entire group. The default is false.

    System.Boolean isLocked

    If set to true, the entire group is locked and cannot be modified by the user. The default value is false.

    Remarks

    This method allows you to programmatically define the entire rule set of the Query Builder.

    SetRulesFromSql(String)

    Sets the rules in the Query Builder from a SQL query string.

    Declaration
    public void SetRulesFromSql(string sqlString = null)
    Parameters
    Type Name Description
    System.String sqlString

    The SQL query string to parse and load. If null, this method has no effect.

    Remarks

    This method parses a SQL WHERE clause and configures the Query Builder's rules based on the parsed query.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved