QueryBuilder
Namespace: Wisej.Web.Ext.Syncfusion2
Assembly: Wisej.Web.Ext.Syncfusion2 (4.1.0.0)
The Query Builder component is a graphical user interface that allows users to create and edit filters. It outputs a structured JSON of filters that can be easily parsed to create SQL.
- C#
- VB.NET
public class QueryBuilder : ej2Base
Public Class QueryBuilder
Inherits ej2Base
Constructors
QueryBuilder()
Constructs a new instance of the QueryBuilder class.
Example:
The following example creates a query builder and defines the fields that can be filtered through the Options object.
var queryBuilder = new QueryBuilder();
queryBuilder.Options.columns = new[]
{
new { field = "name", label = "Name", type = "string" },
new { field = "age", label = "Age", type = "number" },
new { field = "active", label = "Active", type = "boolean" }
};
queryBuilder.Dock = DockStyle.Top;
this.Controls.Add(queryBuilder);
QueryBuilder(options)
Constructs a new instance of the QueryBuilder class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates a query builder with an initial rule and then retrieves the filter built by the user as a SQL expression.
var queryBuilder = new QueryBuilder(new
{
columns = new[]
{
new { field = "country", label = "Country", type = "string" },
new { field = "total", label = "Total", type = "number" }
},
rule = new
{
condition = "and",
rules = new[] { new { field = "total", label = "Total", type = "number", @operator = "greaterthan", value = 1000 } }
}
});
this.Controls.Add(queryBuilder);
// i.e. "total > 1000".
string where = await queryBuilder.Instance.getSqlFromRulesAsync();