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

QueryBuilder custom header template not holding selected value

This solution provided in this forum post
https://www.syncfusion.com/forums/171587/bug-in-query-builder
does not work if you upgrade syncfusion to 
20.3.61.  When you select AND/OR from the dropdown it stays at the original selection.


9 Replies

YA YuvanShankar Arunagiri Syncfusion Team March 22, 2023 09:46 AM UTC

Hi Hakop,


We have checked your reported query and kindly refer to the below code snippet to resolve this issue.


<HeaderTemplate>

                        @{

                            @if (condition == null) {

                                condition = (string)context.Condition;

                            }                         

                        }

<SfDropDownList ID="@context.ID" @bind-Value="@condition" TValue="string" TItem="Condition" CssClass="e-outline" Width="100px" DataSource="@ConditionsList">

…..

  private string condition;

private void conditionChange(ChangeEventArgs<string, Condition> args, HeaderTemplateModel model)

    {

        if (args.IsInteracted)

        {

            model.Condition = args.Value.ToLower();

            condition = args.Value;

        }

    }


And please refer to the below UG link for how condition value changes properly in header template using the Created event instead Value property of dropdown list component.


UG link: https://blazor.syncfusion.com/documentation/query-builder/templates#header-template


Check with attached sample code file and get back to us if you need any further assistance on this. 


Regards,

YuvanShankar A


Attachment: Index_ca9b0d06.zip


HB Hakop Balyan March 22, 2023 04:23 PM UTC

Is this the recommended way of handling this type of change? A global variable changes all the conditions on the querybuilder.



HB Hakop Balyan March 24, 2023 04:14 PM UTC

I had to do something like this to get the Condition to update:


string groupString = model.ID.Replace("querybuilder_group", "");
Int32.TryParse(groupString, out group);
QueryBuilderObj.GetRules().Rules[group].Condition = args.Value.ToLower();

Unfortunately it does not work for the top level group condition, that Condition always reverts back to the starting condition.



YA YuvanShankar Arunagiri Syncfusion Team March 28, 2023 12:14 PM UTC

Hakop,


Sorry for the delay. We have checked your reported query and kindly refer to the below code snippet and attached sample file. Using the Created event of dropdown list component, we can assign the value to dropdown list through Value property as shown as below.


UG link: https://blazor.syncfusion.com/documentation/query-builder/templates#header-template


<HeaderTemplate>                     

                        <SfDropDownList ID="@context.ID" TValue="string" TItem="Condition" CssClass="e-outline" Width="100px" DataSource="@ConditionsList" @ref="ddlObj">

                            <DropDownListFieldSettings Text="Text" Value="Value"></DropDownListFieldSettings>

                            <DropDownListEvents TValue="string" TItem="Condition" Created="e => ddlCreated(e, context)" ValueChange="e => conditionChange(e, context)"></DropDownListEvents>

                        </SfDropDownList>

…..

SfDropDownList<string, Condition> ddlObj { set { ddlRefs.Add(value); } }

    List<SfDropDownList<string, Condition>> ddlRefs = new List<SfDropDownList<string, Condition>>();

private void ddlCreated(Object obj, HeaderTemplateModel model)

    {

        foreach (SfDropDownList<string, Condition> ddlObj in ddlRefs)

        {

            if (ddlObj.ID == model.ID)

            {

                ddlObj.Value = model.Condition.ToLower();

            }

        }

    }


Check with attached sample code file and get back to us if you need any further assistance on this. 


Attachment: Counter_8c985dd2.zip


HB Hakop Balyan March 29, 2023 11:25 PM UTC

this solution does not appear to set the values in the RuleSet which is really what we need


If u look here, everything is unchanged.

QueryBuilderObj.GetRules()


So when i save the data values are incorrect.  Am i missing something?



YA YuvanShankar Arunagiri Syncfusion Team April 3, 2023 02:30 PM UTC

Sorry for the delay, Hakop.


We have confirmed the issue as “Condition value not update properly in Query builder ruleset while using header template" and logged a defect report. We will include the fix for this issue in upcoming weekly patch release scheduled for mid of April 2023.


Feedback link: https://www.syncfusion.com/feedback/42621/condition-value-not-update-properly-in-query-builder-ruleset-while-using-header


You will be informed regarding this once the fix is published.


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”



HB Hakop Balyan April 5, 2023 09:28 PM UTC

thanks, however we will be developing our own version of this component to better fit our needs.



YA YuvanShankar Arunagiri Syncfusion Team April 11, 2023 07:13 AM UTC

Okay, Hakop. If any assistance is needed for Syncfusion controls, please get back to us. The promised fix will be available publicly, and you can use it if needed.



YA YuvanShankar Arunagiri Syncfusion Team April 19, 2023 01:09 PM UTC

Hi Hakop,


We are glad to announce our weekly patch release (21.1.41) is rolled out. We have included the fix for this Condition value not update properly in Query builder ruleset while using header template issue in this release. So, we suggest you upgrade our Syncfusion packages to our latest version to resolve this issue in your end (21.1.41).


Feedback link: https://www.syncfusion.com/feedback/42621/condition-value-not-update-properly-in-query-builder-ruleset-while-using-header

Release notes: https://blazor.syncfusion.com/documentation/release-notes/21.1.41?type=all#querybuilder


Regards,

YuvanShankar A


Loader.
Up arrow icon