Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to reset the CQ.ext.QueryBuilder and CQ.Ext.Form ?

Riyaz_Mohd
Level 2
Level 2

HI,

I am using the CQ's Dam search for fulltext search.

I am creating a form and setting the queryBuilder to the form. On load of the page, i am setting the predicates and filters and submitting the querybuilder, which is giving the results as expected.

Now I have changed my criteria for search, for which i need to change the existing paths set to the query builder. 

I am trying to do so, but it is not resetting the paths and appending the new paths to existing ones, which results to wrong results. 

can anyone help me in resetting the paths?

Here is my initial form and QB:

<form id="querybuilder-<%= time %>-form">
<script type="text/javascript">
    FullTextSearchFeature.defaultUrl = '<%=defaultUrl%>';
    CQ.Ext.onLoad(function() {
        /***** i18n start ****/
        CQ.I18n.setLocale('<%=language %>');     
        /*** i18n end ***/
        var form = new CQ.Ext.form.BasicForm("querybuilder-<%= time %>-form", {
            "method": "POST",
            "url": "<%= properties.get("url", "/bin/querybuilder.json")%>"
        });
        var qb = new CQ.search.QueryBuilder({
            "form": form,
            "renderFieldsTo": "querybuilder-<%= time %>-form"
        });

        CQ.search.Util.setQueryBuilder(qb);
    });

</script>
    <cq:include script="body.jsp"/>
</form>

--------------

Here I am resetting the form/querybuilder:

var form = new CQ.Ext.form.BasicForm(currentQueryBuilder.form.id, {
            "method": "POST",
            "url": FullTextSearchFeature.defaultUrl
        });
        form = form.reset(); 
        var currentQueryBuilder = new CQ.search.QueryBuilder({
            "form": form,
            "renderFieldsTo": currentQueryBuilder.form.id
        }); 
        

CQ.search.Util.setQueryBuilder(currentQueryBuilder); 

Thanks in advance.

0 Replies