Initialize query builder with sql filter
Hi Support,
i found an article to initialize the query builder component (https://blazor.syncfusion.com/documentation/query-builder/import-export/#initial-rendering ). I would initialize the query builder with a sql query passed as parameter to the blazor page, instead of a JSON object.
How can i achieve this?
Best regards
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
MK
Mohan Kumar Ramasamy
Syncfusion Team
September 14, 2020 12:49 PM UTC
Hi Marco,
We have checked your reported query, we can achieve your requirement using SetRulesFromSql method in Created event. Please refer the below code snippet.
|
<SfQueryBuilder DataSource="@EmployeeDetails" @ref="QueryBuilderObj">
<QueryBuilderEvents Created="Created"></QueryBuilderEvents>
<QueryBuilderColumns>
<QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="number"></QueryBuilderColumn>
<QueryBuilderColumn Field="FirstName" Label="First Name" Type="string"></QueryBuilderColumn>
<QueryBuilderColumn Field="TitleOfCourtesy" Label="Title Of Courtesy" Type="boolean"></QueryBuilderColumn>
<QueryBuilderColumn Field="HireDate" Label="Hire Date" Type="date"></QueryBuilderColumn>
<QueryBuilderColumn Field="Country" Label="Country" Type="string"></QueryBuilderColumn>
<QueryBuilderColumn Field="City" Label="City" Type="string"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
@code {
SfQueryBuilder QueryBuilderObj;
private void Created()
{
QueryBuilderObj.SetRulesFromSql("EmployeeID = 1001 and City LIKE ('%Manchester')");
}
}
|
For your convenience, we have prepared a sample based on this. Please find the below sample link
Please check the above sample and get back to us if you need further assistance on this.
Regards,
Mohankumar R
JI
Jim
March 25, 2021 04:15 AM UTC
I tried to update the sample project to the latest version 18.4.0.49 and it throws an error.
blazor.server.js:19 [2021-03-25T04:08:34.493Z] Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'string' to 'double?'
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at Syncfusion.Blazor.QueryBuilder.Internal.QueryBuilderRules`1.SetOperator()
at Syncfusion.Blazor.QueryBuilder.Internal.QueryBuilderRules`1.OnParametersSetAsync()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
<SfQueryBuilder DataSource="@EmployeeDetails" @ref="QueryBuilderObj">
<QueryBuilderEvents TValue="Employee" Created="Created"></QueryBuilderEvents>
<QueryBuilderColumns>
<QueryBuilderColumn Field="EmployeeID" Label="Employee ID" Type="ColumnType.Number"></QueryBuilderColumn>
<QueryBuilderColumn Field="FirstName" Label="First Name" Type="ColumnType.String"></QueryBuilderColumn>
<QueryBuilderColumn Field="TitleOfCourtesy" Label="Title Of Courtesy" Type="ColumnType.Boolean"></QueryBuilderColumn>
<QueryBuilderColumn Field="HireDate" Label="Hire Date" Type="ColumnType.Date"></QueryBuilderColumn>
<QueryBuilderColumn Field="Country" Label="Country" Type="ColumnType.String"></QueryBuilderColumn>
<QueryBuilderColumn Field="City" Label="City" Type="ColumnType.String"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
Can you please help me find the fix?
GK
Gayathri KarunaiAnandam
Syncfusion Team
March 25, 2021 12:32 PM UTC
Hi Marco,
We have checked your reported query. We can be able to replicate the reported issue in our end. We have confirmed this as an issue from our side. We have logged a bug report for this. You can track its status from the below feedback link.
The fix will be provided in our patch release which will be scheduled on 15th April,2021.
We appreciate your patience until then.
Regards,
Gayathri K
Marked as answer
JI
Jim
March 25, 2021 02:00 PM UTC
I'm not Marco, but thanks anyway.
GK
Gayathri KarunaiAnandam
Syncfusion Team
March 26, 2021 05:51 AM UTC
Hi Jim,
Sorry for the inconvenience caused. We will provide this support as promised.
Regards,
Gayathri K
SIGN IN To post a reply.