We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using QueryBuilder without model fields

Hello,

we have to populate a model in our website with a list of skill expressions like this one:

English>5 & Accounting>=1

This means I have a list of existing skills to select and not a model of which I can use its fields. Is it still possible for me to use the QueryBuilder component and what would be the best approach for this?

The reason for even considering the query builder is that the general building of querys is exactly what I want - just not based on a model and its fields.

Thank you for your help!

Best regards,

Marco


1 Reply 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team December 5, 2022 04:19 PM UTC

Hi Macro,


Sorry for the delay. Using the list of skill data, we can render the query builder without the model field/class. Please refer the below code snippet.


@using Syncfusion.Blazor.QueryBuilder

 

<SfQueryBuilder TValue="string">

    <QueryBuilderRule Condition="and" Rules="Rules"></QueryBuilderRule>

    <QueryBuilderColumns>

        @foreach (string Skill in Skills)

        {

            <QueryBuilderColumn Field="@Skill" Label="@Skill" Type="ColumnType.Number"></QueryBuilderColumn>

        }

    </QueryBuilderColumns>

</SfQueryBuilder>

 

@code {

    private List<string> Skills = new List<string> { "English", "Accounting", "Maths", "Economics", "Physics" };

    List<RuleModel> Rules = new List<RuleModel>()

    {

        new RuleModel { Field="English", Label="English", Type="Number", Operator="greaterthan", Value = 5 },

        new RuleModel { Field="Accounting", Label="Accounting",  Type="Number", Operator="greaterthanorequal", Value = 1 }

    };

}


Please get back to us, if you need any assistance on this.


Regards,

YuvanShankar A


Marked as answer
Loader.
Up arrow icon