Skip to main content
Version: 4.2

QueryBuilder

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

Edits nested, typed AND/OR query rules with an optional expression preview.

public class QueryBuilder : Control

Fields use the reusable FilterField model. All accepted edits are validated on the server. The expression is a display DSL, not executable SQL. Translate the model to parameterized queries in application code. Root depth is zero; MaxDepth counts child levels.

Example:

var builder = new QueryBuilder { Dock = DockStyle.Fill };
builder.Fields.Add(new FilterField("CPU", "CPU", FilterFieldType.Number));
builder.Root.Rules.Add(new QueryRule("CPU", QueryOperator.GreaterThan, "80"));
builder.QueryChanged += (sender, e) => Console.WriteLine(builder.ToExpression());
Controls.Add(builder);

Constructors​

Instance member QueryBuilder()​

Creates an empty AND query with up to three nested group levels.

Properties​

Instance member AddGroupText​

String: Gets or sets the localized override for the "+ Group" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member AddRuleText​

String: Gets or sets the localized override for the "+ Rule" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member AllText​

String: Gets or sets the localized override for the "ALL" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member AnyText​

String: Gets or sets the localized override for the "ANY" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member ComparisonAccessibleText​

String: Gets or sets the localized override for the "Comparison" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member ContainsText​

String: Gets or sets the localized override for the "contains" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Protected member DefaultSize​

Size: Returns the default size of the control.

Value: The default Size of the control.

Instance member EqualText​

String: Gets or sets the localized override for the "is" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member FalseText​

String: Gets or sets the localized override for the "false" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member FieldAccessibleText​

String: Gets or sets the localized override for the "Field" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member Fields​

FilterFieldCollection: Gets the shared field metadata. Removing a field used by a rule is rejected.

Instance member GroupConditionText​

String: Gets or sets the localized override for the "of the following are true" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member IsEmptyText​

String: Gets or sets the localized override for the "is empty" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member IsNotEmptyText​

String: Gets or sets the localized override for the "is not empty" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member MaxDepth​

Int32: Gets or sets the maximum child-group depth, from zero to sixteen. The root has depth zero. (Default: 3)

Instance member NestedGroupText​

String: Gets or sets the localized override for the "nested group" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member NoRulesText​

String: Gets or sets the localized override for the "No rules" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member NotEqualText​

String: Gets or sets the localized override for the "is not" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member RemoveGroupText​

String: Gets or sets the localized override for the "Remove group" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member RemoveRuleText​

String: Gets or sets the localized override for the "Remove rule" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member Root​

QueryGroup: Gets or sets the live query tree.

Attached edits notify automatically. Invalid assignments and edits are rolled back. A group or rule cannot be shared between trees or occur twice in a tree. Replacing Root raises RuleRemoved for old rules and RuleAdded for new rules before QueryChanged.

Instance member ShowPreview​

Boolean: Gets or sets whether to display the read-only expression preview. (Default: True)

Instance member StartsWithText​

String: Gets or sets the localized override for the "starts with" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member TrueText​

String: Gets or sets the localized override for the "true" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member ValueAccessibleText​

String: Gets or sets the localized override for the "{0} value" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the field caption. Literal braces can be written as {{ and }}.

Methods​

Protected member Dispose(disposing)​

Disposes the control.

ParameterTypeDescription
disposingBooleantrue when this method is called by the application rather than a finalizer.

Instance member FromJson(json)​

Atomically replaces the query with a validated JSON tree.

ParameterTypeDescription
jsonStringJSON previously produced by ToJson, or the equivalent documented structure.

Configure Fields before importing. Unknown fields, invalid operators and literals, extra properties, more than 512 nodes, and excess nesting are rejected. The existing query is preserved on failure. Payloads are limited to 1 MB of characters.

Example:

string savedQuery = builder.ToJson();
builder.FromJson(savedQuery);

Protected member OnQueryChanged(e)​

Raises the QueryChanged event.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnRuleAdded(e)​

Raises the RuleAdded event.

ParameterTypeDescription
eQueryRuleEventArgsEvent data.

Protected member OnRuleRemoved(e)​

Raises the RuleRemoved event.

ParameterTypeDescription
eQueryRuleEventArgsEvent data.

Protected member OnWebEvent(e)​

Dispatches client edit events to server validation.

ParameterTypeDescription
eWisejEventArgsClient event.

Protected member OnWebRender(config)​

Renders first-level widget properties and wires the edit event unconditionally.

ParameterTypeDescription
configObjectClient configuration.

Instance member ToExpression()​

Formats the query as a human-readable expression, omitting empty groups.

Returns: String. The display expression.

Field keys are bracketed with closing brackets escaped by doubling. Text, choice, and date literals are single-quoted with quotes doubled. Numeric and boolean literals are invariant. CONTAINS and STARTS WITH are display operators. An empty query returns an empty string. This is not a SQL, LINQ, or executable expression generator.

Instance member ToJson()​

Serializes the rule tree using stable field keys and invariant string literals.

Returns: String. A JSON object with logic, rules, and groups arrays; metadata is not included.

Events​

Instance member QueryChanged​

EventHandler Occurs after an accepted query or field metadata change.

Instance member RuleAdded​

EventHandler<QueryRuleEventArgs> Occurs for each rule entering the query, including rules in a newly added group.

Instance member RuleRemoved​

EventHandler<QueryRuleEventArgs> Occurs for each rule leaving the query, including rules in a removed group.

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IBindableComponentBindable components implement this interface.
IDropTargetControls that support drag & drop operations implement this interface.
IWisejComponentAll wisej components implement this interface.
IWisejControlAll wisej controls derived from the Control class must implement this interface.
IWisejSerializableAllows an object to serialize itself.