I am trying to create custom operators for a QueryBuilderColumn, however the operators list is not being honored. Below is a snippit of my implementation. What am I missing? This seems like quite a simplistic implementation, however the default operators are showing, not my list of operators specified.
<SfQueryBuilder TValue="Customer" MaxGroupCount="0">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
@code{
public List<OperatorsModel> cOperators = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
}
<SfQueryBuilder TValue="string[]" MaxGroupCount="0">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
@code{
public List<OperatorsModel> cOperators = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
} |
Hi Gayathri,
I spent some time troubleshooting this more and I believe I found a bug in the querybuildercomponent. In my project the querybuilder is inside a blazor component, which is shown in a sidebar component. For some reason, If the blazor component that hosts the querycomponent accepts parameters of type Guid or an eventcallback or Action, the custom operators for the querycomponent is not honored. Below code and example project attached. Could you please confirm that it is a bug?
Main Component / Page
<SfSidebar @ref="SidebarObj" Position="@Position" HtmlAttributes="@HtmlAttribute" @bind-IsOpen="SidebarToggle">
<ChildContent>
@if (SidebarToggle)
{
//Querycomponent that renders custom operators correctly
<QueryComponent TestParam="test"></QueryComponent>
//Querycomponent that DOES NOT render custom operators correctly
<QueryComponent2 testParam="@TestGuid"></QueryComponent2>
}
</ChildContent>
</SfSidebar>
QueryComponent1 (With querycomponent that renders custom operators correctly)
<SfQueryBuilder TValue="string[]" MaxGroupCount="0">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
<div>Test Param: @TestParam</div>
@code{
[Parameter] public string TestParam { get; set; }
public List<OperatorsModel> cOperators = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
}
QueryComponent2 (With querybuilder that does not render custom operators)
<SfQueryBuilder TValue="string[]" MaxGroupCount="0">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
@code{
[Parameter] public Guid testParam { get; set; }
public List<OperatorsModel> cOperators = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
}
<div class="control-section">
<div id="wrapper">
<div class="col-lg-12 col-sm-12 col-md-12" id="sidebar-section">
<!-- sidebar element declaration -->
<span id="hamburger" @onclick="@Show" class="@Hamburgerclass"></span>
<SfSidebar @ref="SidebarObj" Position="@Position" HtmlAttributes="@HtmlAttribute" @bind-IsOpen="SidebarToggle">
<ChildContent>
@if (SidebarToggle)
{
//Querycomponent that renders custom operators correctly
<QueryComponent TestParam="test"></QueryComponent>
//Querycomponent that DOES NOT render custom operators correctly
<QueryComponent2 testParam="@TestGuidValue"></QueryComponent2>
}
</ChildContent>
</SfSidebar>
<!-- end of sidebar element -->
<!-- main content declaration -->
<div>
<div class="title default">Main content</div>
<div class="sub-title">
Click the button to open/close the Sidebar.
<div style="padding:20px" class="center-align">
<!-- button element declaration -->
<SfButton @onclick="Toggle" CssClass="e-btn e-info">Toggle Sidebar</SfButton>
</div>
</div>
</div>
</div>
<!--end of main content declaration -->
</div>
</div>
@code {
public string TestGuidValue { get; set; }
public Guid TestGuid { get; set; } = Guid.Parse("19ADF783-C733-494A-A4CE-3ED8EC0930DD");
protected override void OnInitialized()
{
TestGuidValue = TestGuid.ToString();
}
} |
@using Syncfusion.Blazor.QueryBuilder
<SfQueryBuilder TValue="string[]" MaxGroupCount="0" ID="Query2">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators2"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
@code{
[Parameter] public string testParam { get; set; }
public List<OperatorsModel> cOperators2 = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
} |
Gayathri,
The problem is not converting to string. The problem is that the querybuilder component is not rendering custom operators when using Parameters in the blazor component other than string. In my main project. the blazor component has an Eventcallback Parameter to report back to the main component (index page) to report when a button (save button) is clicked, so the UI on the main page can be updated.
So. Yes, your example above works around the QueryBuilder component error, but it does not resolve the underlying issue with the querybuilder component.
Let's take a different approach. Same example, using an eventcallback in the blazor component as an example, rather than a Guid. (I Also updated the sample which is attached)
This still does not render the custom operators correctly. How would you work around this, or is there a bug in the QueryBuilder component that needs to be fixed?
index.razor
@page "/"
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Buttons
<div class="control-section">
<div id="wrapper">
<div class="col-lg-12 col-sm-12 col-md-12" id="sidebar-section">
<!-- sidebar element declaration -->
<span id="hamburger" @onclick="@Show" class="@Hamburgerclass"></span>
<SfSidebar @ref="SidebarObj" Position="@Position" HtmlAttributes="@HtmlAttribute" @bind-IsOpen="SidebarToggle">
<ChildContent>
@if (SidebarToggle)
{
//Querycomponent that renders custom operators correctly
<QueryComponent TestParam="test"></QueryComponent>
//Querycomponent that DOES NOT render custom operators correctly
<QueryComponent2 cmdCompleted="QueryUpdated"></QueryComponent2>
}
</ChildContent>
</SfSidebar>
<!-- end of sidebar element -->
<!-- main content declaration -->
<div>
<div class="title default">Main content</div>
<div class="sub-title">
Click the button to open/close the Sidebar.
<div style="padding:20px" class="center-align">
<!-- button element declaration -->
<SfButton @onclick="Toggle" CssClass="e-btn e-info">Toggle Sidebar</SfButton>
</div>
</div>
</div>
</div>
<!--end of main content declaration -->
</div>
</div>
@code {
SfSidebar SidebarObj;
public string Leftbtn = "Left";
public string Hamburgerclass = "e-icons menu default";
public SidebarPosition Position { get; set; } = SidebarPosition.Left;
public bool SidebarToggle = false;
public void Show()
{
SidebarToggle = true;
}
public void Close()
{
SidebarToggle = false;
}
public void Toggle()
{
SidebarToggle = !SidebarToggle;
}
public void PositionChange(Syncfusion.Blazor.Buttons.ChangeArgs<string> args)
{
if (args.Value == "Left")
{
this.Position = SidebarPosition.Left;
this.Hamburgerclass = "e-icons menu default";
}
else
{
this.Position = SidebarPosition.Right;
this.Hamburgerclass = "e-icons menu default e-rtl";
}
}
Dictionary<string, object> HtmlAttribute = new Dictionary<string, object>()
{
{"class", "default-sidebar" }
};
public async Task QueryUpdated()
{
//Do stuff
SidebarToggle = false;
}
}
QueryComponent2.razor
<SfQueryBuilder TValue="string[]" MaxGroupCount="0">
<QueryBuilderColumns>
<QueryBuilderColumn Field="Name" Label="Name" Type=Syncfusion.Blazor.QueryBuilder.ColumnType.String Operators="@cOperators"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
<Syncfusion.Blazor.Buttons.SfButton OnClick="ReportToParent">Save</Syncfusion.Blazor.Buttons.SfButton>
@code{
[Parameter] public EventCallback<string> cmdCompleted { get; set; }
public List<OperatorsModel> cOperators = new List<OperatorsModel> {
new OperatorsModel { Text="Equal", Value="equal"},
new OperatorsModel { Text="Not equal", Value="notequal"}
};
public async void ReportToParent()
{
await cmdCompleted.InvokeAsync();
}
}
Thanks, awaiting your reply.
Gayathri,
There has been two releases since your promise on Aug 10. This issue is currently blocking our projects and no further development is possible... When will this be fixed?