Class SfQueryBuilder<TValue>
Query Builder is a graphical user interface that used for filtering large amounts of data by creating or editing conditions.
Inherited Members
Namespace: Syncfusion.Blazor.QueryBuilder
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfQueryBuilder<TValue> : SfDataBoundComponent, IQueryBuilder
Type Parameters
Name |
---|
TValue |
Constructors
SfQueryBuilder()
Declaration
public SfQueryBuilder()
Properties
AllowDragAndDrop
Gets or sets a value indicating whether the drag and drop option for rules/ groups is enabled in the SfQueryBuilder<TValue> to move the rules/ groups.
Declaration
public bool AllowDragAndDrop { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When this property is set to true, the drag handle will be rendered in front of the rule/ group element to perform, drag and drop. When set to false, the drag handle element is not rendered.
AllowValidation
Gets or sets a value that indicates whether to enables or disables the validation.
Declaration
public bool AllowValidation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ChildContent
Gets or sets a value that indicates content for query builder element including HTML and its customizations.
Declaration
public RenderFragment ChildContent { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment | Accepts a RenderFragment that defines the content of the UI element. |
ColumnTemplate
Gets or sets a value that indicates the template for all columns.
Declaration
public RenderFragment<RuleModel> ColumnTemplate { get; set; }
Property Value
Type |
---|
Microsoft.AspNetCore.Components.RenderFragment<RuleModel> |
CssClass
Gets or sets CSS class string to customize the appearance of querybuilder.
Declaration
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts a CSS class string separated by space to customize the appearance of querybuilder. The default value is |
DataSource
Gets or sets a value that indicates the data source of querybuilder.
Declaration
public IEnumerable<TValue> DataSource { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TValue> | Accepts the list items either through local or remote service and binds it to the component. |
DefaultSelectedField
Gets or sets the default field to be selected when inserting a new rule or group in the SfQueryBuilder.
Declaration
public string DefaultSelectedField { get; set; }
Property Value
Type | Description |
---|---|
System.String | The field name string to be selected. The default value is an empty string. |
Remarks
The field dropdown will render with the specified value. The operator and value controls will be rendered once the field gets selected in the field dropdown list. If set to an empty string, the dropdown list renders with a placeholder.
DefaultSelectedOperator
Gets or sets the default operator to be selected when inserting a new rule / group or changing fields in the SfQueryBuilder.
Declaration
public QueryBuilderOperatorType DefaultSelectedOperator { get; set; }
Property Value
Type | Description |
---|---|
QueryBuilderOperatorType | The |
Remarks
The operator dropdown will render with the specified value. The value controls will be rendered once the operator gets selected in the operator dropdown list. If set to an empty string, the dropdown list renders with a placeholder.
DisplayMode
Gets or sets a value that indicates the displayMode as Horizontal or Vertical.
Declaration
public DisplayMode DisplayMode { get; set; }
Property Value
Type | Description |
---|---|
DisplayMode | One of the |
Remarks
If the DisplayMode
is Horizontal
, the columns will be aligned horizontally.
If the DisplayMode
is Vertical
, the columns will be aligned vertically.
EnableIndividualConditions
Gets or sets a value indicating whether rules and groups are connected using separate connectors in the SfQueryBuilder<TValue>.
Declaration
public bool EnableIndividualConditions { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When this property is set to true
, each rule or group will have its own connector, allowing them to be connected separately with different connectors.
When set to false
, connectors will be shared between rules and groups, possibly connecting them with the same connector.
EnableNotCondition
Gets or sets a value that indicates whether to enable or disable the not group condition in query builder.
Declaration
public bool EnableNotCondition { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnablePersistence
Gets or sets a value that indicates whether to enable or disable persisting component's state between page reloads.
Declaration
public bool EnablePersistence { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableRtl
Gets or sets a value that indicates whether to enable or disable the right to left direction option in query builder.
Declaration
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Height
Gets or sets a value that indicates the height of the query builder.
Declaration
public string Height { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. The default value is |
ID
Gets or sets a value that indicates the id attribute for query builder element.
Declaration
public string ID { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
ImmediateModeDelay
Gets or sets a value that indicates the time delay to trigger the rule change event.
Declaration
public double ImmediateModeDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Accepts double value and the rule change event is triggered after that specified time delay. |
MatchCase
Gets or sets a value that indicates whether to enable or disable the grid filtering with exact match.
Declaration
public bool MatchCase { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
MaxGroupCount
Gets or sets a value that indicates the maximum group count or restricts the group count.
Declaration
public int MaxGroupCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Accepts an integer value. The default value is |
Readonly
Gets or sets a value that indicates whether to enable or disable the user interactions in the component.
Declaration
public bool Readonly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Separator
Gets or sets a value that indicates the separator for complex data binding.
Declaration
public string Separator { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
SortDirection
Gets or sets a value that indicates the sort direction of the field names.
Declaration
public SortDirection SortDirection { get; set; }
Property Value
Type | Description |
---|---|
SortDirection | One of the |
Remarks
If the SortDirection
is Default
, the field names will be ordered in default order.
If the SortDirection
is Ascending
, the field names will be ordered in ascending order.
If the SortDirection
is Descending
, the field names will be ordered in descending order.
SummaryView
Gets or sets a value that indicates whether to enable or disable filtered query as summary view.
Declaration
public bool SummaryView { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
UniqueFilterMode
Gets or sets whether to allow creating multiple filter conditions for a field in a group or all groups. Be default, end-user can create multiple filter conditions for a field. The unique filter option for the fields in query builder where once filter condition created for a field then you can prevent creating further conditions in a group or for all groups.
Declaration
public UniqueFilterMode UniqueFilterMode { get; set; }
Property Value
Type | Description |
---|---|
UniqueFilterMode | One of the UniqueFilterMode enumeration. The default value is None. |
Width
Gets or sets a value that indicates the width of the query builder.
Declaration
public string Width { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. The default value is |
Methods
AddGroup(RuleModel, String)
Adds single or multiple groups, which contains the collection of rules.
Declaration
public void AddGroup(RuleModel group, string groupID)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | group | Groups be passed to add the group. |
System.String | groupID | GroupID be be added in the group. |
AddRule(RuleModel, String, Boolean)
Adds the specified rule into the group which is specified using GroupID
parameter.
Declaration
public void AddRule(RuleModel rule, string groupID, bool isGroupRule = false)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | The rule be passed to add the rules. |
System.String | groupID | The groupID to be passed to specify the group to add rules. |
System.Boolean | isGroupRule | To add the rule under the respected group tree. |
Remarks
The rule can be added as group of rules if the IsGroupRule>
property is true other wise it is added at the bottom of the group.
Examples
In the below code example, AddRule
is used to insert the rule.
<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;
private string groupID;
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(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 the group based on the group ID to the specific group in the SfQueryBuilder<TValue>.
Declaration
public void CloneGroup(string groupID, int index = -1)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupID | Specifies the groupID that needs to be cloned. |
System.Int32 | index | Specifies the index to insert the cloned group inside the group. |
CloneRule(String, Int32)
Clones the rule based on the rule ID to the specific group in the SfQueryBuilder<TValue>.
Declaration
public void CloneRule(string ruleID, int index = -1)
Parameters
Type | Name | Description |
---|---|---|
System.String | ruleID | Specifies the ruleID that needs to be cloned. |
System.Int32 | index | Specifies the index to insert the cloned rule inside the group. |
DeleteGroup(String)
Deletes the group or groups based on the group ID.
Declaration
public void DeleteGroup(string groupId)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupId | GroupId be passed to delete the group. |
DeleteRule(String)
Deletes the rule or rules based on the rule ID.
Declaration
public void DeleteRule(string ruleId)
Parameters
Type | Name | Description |
---|---|---|
System.String | ruleId | RuleId be passed to delete the rule. |
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
GetColumn(String)
Gets the column of given field.
Declaration
public ColumnsModel GetColumn(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Field be passed to get the column. |
Returns
Type |
---|
Syncfusion.Blazor.QueryBuilder.Internal.ColumnsModel |
GetDataManagerQuery(RuleModel)
Gets the query for Data Manager.
Declaration
public Query GetDataManagerQuery(RuleModel rule = null)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Rule be passed to get the query. |
Returns
Type | Description |
---|---|
Query | It returns the data manger |
GetFilteredRecords()
Gets the filtered records using the created rules.
Declaration
public IEnumerable<TValue> GetFilteredRecords()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TValue> | It returns collection of records. |
GetFilteredRecordsAsync()
Gets the filtered records using the created rules.
Declaration
public Task<IEnumerable<TValue>> GetFilteredRecordsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TValue>> | It returns collection of records. |
GetGroup()
Gets the group.
Declaration
public RuleModel GetGroup()
Returns
Type | Description |
---|---|
RuleModel | It returns the valid rules as |
GetMongoQuery(RuleModel)
Gets mongo query from SfQueryBuilder<TValue> based on the rule model.
Declaration
public string GetMongoQuery(RuleModel rule)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Specifies the RuleModel to be used to get the mongo query. |
Returns
Type | Description |
---|---|
System.String | A string which represents the mongo query. |
Remarks
The value returned by this method is used to filter the records from the Mongo DB using BsonDocument.
GetNamedParameterSql(RuleModel)
Gets parameterized named SQL query from SfQueryBuilder<TValue> based on the rule model.
Declaration
public NamedParameterSql GetNamedParameterSql(RuleModel rule = null)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Specifies the RuleModel to be used to get the parameterized named SQL query. |
Returns
Type | Description |
---|---|
NamedParameterSql | A NamedParameterSql which represents the parameterized named SQL query. |
Remarks
The value returned by this method is used to filter the records from the SQL related databases.
GetOperators(String)
Gets the operators list for given field.
Declaration
public List<OperatorsModel> GetOperators(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Fields be passed to get the operators. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<OperatorsModel> | It returns the collection of operators as |
GetParameterSql(RuleModel)
Gets parameterized SQL query from SfQueryBuilder<TValue> based on the rule model.
Declaration
public ParameterSql GetParameterSql(RuleModel rule = null)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Specifies the RuleModel to be used to get the parameterized SQL query. |
Returns
Type | Description |
---|---|
ParameterSql | A ParameterSql which represents the parameterized SQL query. |
Remarks
The value returned by this method is used to filter the records from the SQL related databases.
GetPredicate(RuleModel)
Gets the predicate from the created rules.
Declaration
public WhereFilter GetPredicate(RuleModel rule = null)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Rule be passed to get the predicate. |
Returns
Type | Description |
---|---|
WhereFilter | It returns the data manager predicates using the created rule. |
GetRule(String)
Gets the RuleModel of a rule or group based on the given ID in a SfQueryBuilder<TValue>.
Declaration
public RuleModel GetRule(string ID)
Parameters
Type | Name | Description |
---|---|---|
System.String | ID |
Returns
Type | Description |
---|---|
RuleModel | The RuleModel corresponding to the provided ID. |
Remarks
It returns the RuleModel of a rule when the ID of the rule is passed to this method. It returns the RuleModel of a group when the ID of the group is passed to this method.
GetRules()
Gets the rule or rule collection.
Declaration
public RuleModel GetRules()
Returns
Type | Description |
---|---|
RuleModel | It returns the reated rule as |
GetRulesFromSql(String)
Gets the rules from the sql query.
Declaration
public RuleModel GetRulesFromSql(string sqlString = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlString | SqlString be passed to get the rules. |
Returns
Type | Description |
---|---|
RuleModel | It returns the rule model from the sql query as |
GetSqlFromRules(RuleModel, Boolean)
Gets the sql query from rules.
Declaration
public string GetSqlFromRules(RuleModel rule = null, bool allowEscape = false)
Parameters
Type | Name | Description |
---|---|---|
RuleModel | rule | Rule be passed to get the sql rules. |
System.Boolean | allowEscape | Set |
Returns
Type | Description |
---|---|
System.String | It returns the sql query from the |
GetValidRules()
Gets the valid rule or rules collection.
Declaration
public RuleModel GetValidRules()
Returns
Type | Description |
---|---|
RuleModel | It returns the rule from the created rules as |
LockGroup(String, Boolean)
Locks the group based on the group ID in the SfQueryBuilder<TValue>.
Declaration
public void LockGroup(string groupID, bool isLocked = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupID | |
System.Boolean | isLocked | Specifies whether the group will be locked or not. |
LockRule(String, Boolean)
Locks the rule based on the rule ID in the SfQueryBuilder<TValue>.
Declaration
public void LockRule(string ruleID, bool isLocked = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | ruleID | Specifies the ruleID that needs to be locked. |
System.Boolean | isLocked | Specifies whether the rule will be locked or not. |
OnAfterRenderAsync(Boolean)
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
Reset()
Clears the rules without root rule.
Declaration
public void Reset()
SetMongoQuery(String)
Sets the given mongo query to the SfQueryBuilder<TValue>.
Declaration
public void SetMongoQuery(string mongoQuery)
Parameters
Type | Name | Description |
---|---|---|
System.String | mongoQuery | Specifies the mongo query to be loaded into the query builder. |
SetNamedParameterSql(NamedParameterSql)
Sets the rules from the parameterized named SQL query to the SfQueryBuilder<TValue>.
Declaration
public void SetNamedParameterSql(NamedParameterSql sqlQuery)
Parameters
Type | Name | Description |
---|---|---|
NamedParameterSql | sqlQuery |
SetParameterSql(ParameterSql)
Sets the rules from the parameterized SQL query to the SfQueryBuilder<TValue>.
Declaration
public void SetParameterSql(ParameterSql sqlQuery)
Parameters
Type | Name | Description |
---|---|---|
ParameterSql | sqlQuery | Specifies the parameterized SQL query to be loaded into the query builder. |
SetRules(List<RuleModel>, String, Nullable<Boolean>, Boolean)
Sets the rule or rules collection.
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 | Rule be passed to set the rules. |
System.String | condition | Condition be passed to set the condition. |
System.Nullable<System.Boolean> | not | Not be passed to set the not condition. |
System.Boolean | isLocked | Specify whether the group is locked or not. |
SetRulesFromSql(String)
Sets the rules from the sql query.
Declaration
public void SetRulesFromSql(string sqlString = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlString | sql string be passed to set the rules. |