Is this binding and filtering possible with Query Builder?
I have seen that there is filtering by nesting, could I use that with this object model?
(ICollection)
And I have another question:
-If I want to relate my parent class to another child class, it is enough for me to do this for bind or filter, right?:
QueryBuilderColumn Field="ClassParent.Child.Name"
In which cases is it recommended to replace this with nesting?
Hi Sergio,
We have checked the reported query and prepared a sample based on your requirements. Kindly refer to the below code snippet.
|
@using Syncfusion.Blazor.QueryBuilder <SfQueryBuilder TValue="ClassParent" Separator="." @ref="QueryBuilderObj"> <QueryBuilderRule Condition="or" Rules="@Rules"></QueryBuilderRule> <QueryBuilderColumns> <QueryBuilderColumn Field="Name" Label="Name" Type="ColumnType.String"></QueryBuilderColumn> <QueryBuilderColumn Field="Child" Label="Child" Type="ColumnType.Object"> <QueryBuilderColumns> <QueryBuilderColumn Field="TypeID" Label="TypeID" Type="ColumnType.String"></QueryBuilderColumn> <QueryBuilderColumn Field="TypeName" Label="TypeName" Type="ColumnType.String"></QueryBuilderColumn> </QueryBuilderColumns> </QueryBuilderColumn> </QueryBuilderColumns> </SfQueryBuilder> @code { SfQueryBuilder<ClassParent> QueryBuilderObj; List<RuleModel> Rules = new List<RuleModel>() { new RuleModel { Field="Name", Label="Name", Type="String", Operator="equal", Value = "Mark" } }; public class ClassParent { public string Name { get; set; } public ClassChild Child { get; set; } } public class ClassChild { public string TypeID { get; set; } public string TypeName { get; set; } } } |
Get back to us if you need any further assistance on this.
Regards,
KeerthiKaran K V
hi,
you have not understood, the class child is an IEnumerable
Sorry for the inconvenience, Sergio. We don’t have support to load the IEnumerable model data source to the columns. The QueryBuilder component only supports the string, number, boolean, and object types of columns. And the object type is used for complex data-binding support, as we shared in our last update, which is similar to your requirement.
For more details about complex data binding in the query builder, kindly refer to the below links.
Demo link: https://blazor.syncfusion.com/demos/query-builder/complex-databinding?theme=fluent
UG link: https://blazor.syncfusion.com/documentation/query-builder/data-binding#complex-data-binding
The class definition should be like this.
|
Using the complex data binding support of query builder, we can set the parent column's object type and child columns within the parent.
|
<SfQueryBuilder TValue="ClassParent" Separator="." > <QueryBuilderColumns> <QueryBuilderColumn Field="Name" Label="Name" Type="ColumnType.String"></QueryBuilderColumn> <QueryBuilderColumn Field="Childs" Label="Childs" Type="ColumnType.Object"> <QueryBuilderColumns> <QueryBuilderColumn Field="MyType" Label="MyType" Type="ColumnType.Object"> <QueryBuilderColumns> <QueryBuilderColumn Field="TypeId" Label="TypeId" Type="ColumnType.Number"></QueryBuilderColumn> <QueryBuilderColumn Field="TypeName" Label="TypeName" Type="ColumnType.String"></QueryBuilderColumn> </QueryBuilderColumns> </QueryBuilderColumn> </QueryBuilderColumns> </QueryBuilderColumn> </QueryBuilderColumns> </SfQueryBuilder> |
Check with attached sample code file and get back to us, if you need any further assistance on this.
Regards,
YuvanShankar