Search results

Getting Started

This section briefly explains about how to include Blazor QueryBuilder in your Blazor client-side application. You can refer Getting Started with Syncfusion Blazor for Client-side in Visual Studio 2019 Preview page for introduction part and configure the common specifications.

Importing Syncfusion Blazor component in the application

  1. Install Syncfusion.EJ2.Blazor NuGet package to the application by using the NuGet Package Manager. Please ensure to check the Include prerelease option.
  2. You can add the client-side resources through CDN or local npm package in the <head> element of the ~/wwwroot/index.html page.
<head>
    <environment include="Development">
        <link href="https://cdn.syncfusion.com/ej2/17.3.29/material.css" rel="stylesheet" />
        <script src="https://cdn.syncfusion.com/ej2/17.3.29/dist/ej2.min.js"></script>
     </environment>
</head>

Adding component package to the application

Open /_Imports.razor file and import the Syncfusion.EJ2.Blazor.QueryBuilder packages.

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.QueryBuilder

Adding QueryBuilder component to the application

Now, add the Blazor QueryBuilder component in razor page in the Pages folder. For example, the QueryBuilder component is added in the ~/Pages/Index.razor page.

<EjsQueryBuilder Columns="@Columns"></EjsQueryBuilder>

    @code {
        public List<QueryBuilderColumn> Columns = new List<QueryBuilderColumn>
        {
            new QueryBuilderColumn{ Field = "EmployeeID", Label = "Employee ID", Type = "number" },
            new QueryBuilderColumn{ Field = "FirstName", Label = "First Name", Type = "string" },
            new QueryBuilderColumn{ Field = "TitleOfCourtesy", Label ="Title of Courtesy", Type = "boolean"},
            new QueryBuilderColumn{ Field = "Title", Label = "Title", Type = "boolean", Values = new List<string>{ "Mr.", "Mrs." } },
            new QueryBuilderColumn{ Field = "HireDate", Label = "Hire Date", Type = "date", Format = "dd/MM/yyyy"},
            new QueryBuilderColumn{ Field = "Country", Label = "Country", Type="string"},
            new QueryBuilderColumn{ Field = "City", Label = "City", Type = "string"}
        };
    }

Run the application

After successful compilation of your application, simply press F5 to run the application. The Blazor QueryBuilder component will render in the web browser as shown below

QueryBuilder Sample

See Also