open a sub query in a Query Widget from a Custom Widget.

147
4
Jump to solution
02-25-2019 01:57 PM
New Contributor III

Hi,

Look at the snap to understand this  better.

1) on Left we have a Custom Widget (red Color).

    it contains list of items (Shelter, Homeless, Food, etc...).

2) on the right we have queries in a Query Widget (Blue Color)

     Each of the list item from our Custom Widget is associated with one of the item in the Query Widget..

Question:

      Click on Shelter in Custom  to open "Shelter" in QueryWidget.

      I was not successful in opening the QueryWidget.

Here is the code I tried //

ClickCustomCategory: function(listItem)
   {  
        var widgetId = "widgets_Query_Widget_38"  //ID of the QueryWidget is known from setting.

        var  queries= this.appConfig.getConfigElementById(widgetId );
        var node = dijit.byId(widgetId ).tasksTbody;      //this gives the Table that contains all the queries in each tr rows.
      if (widgets.length === 0) {
          alert("No Target Widget configured.")
         return;
      }

   var QueryNodes = dijit.byId(this.config.selTargetwidget).tasksTbody;

     for (child in QueryNodes .children) {
    if (  listItem== QueryNodes .children[child].innerText)
          {
                 //open the QueryNode panel here
           }
}

Reply
0 Kudos
1 Solution

Accepted Solutions
MVP Esteemed Contributor

Here is what will work:

//add these to your widgets define array
'jimu/WidgetManager',
'dijit/registry'

....


this.qWidget = WidgetManager.getInstance().getWidgetsByName("Query")[0];

var QueryNodes = registry.byId(this.qWidget.id).tasksTbody;
for (child in QueryNodes.children) {
var node = QueryNodes.children[child];
var label = node.innerText.trim();
if (listItem == label){
this.qWidget._onClickTaskTr(node);
}
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

Reply
0 Kudos
4 Replies
MVP Esteemed Contributor

Here is what will work:

//add these to your widgets define array
'jimu/WidgetManager',
'dijit/registry'

....


this.qWidget = WidgetManager.getInstance().getWidgetsByName("Query")[0];

var QueryNodes = registry.byId(this.qWidget.id).tasksTbody;
for (child in QueryNodes.children) {
var node = QueryNodes.children[child];
var label = node.innerText.trim();
if (listItem == label){
this.qWidget._onClickTaskTr(node);
}
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

Reply
0 Kudos
New Contributor III

Thank you so much.This was perfect.

Reply
0 Kudos
New Contributor III

Hi Robert,

This worked for "Shelter" item only. But all the other Items  example: when I click "Homeless Resource" or "Food", etc it gives me the following error.

init.js:115 lang.hitch: scope["_onLoadMoreClicked"] is null (scope="[Widget uniqName_0, uniqName_0_29]")
----------------------------------------
rejected at a (https://js.arcgis.com/3.27/init.js:109:174)
at l (https://js.arcgis.com/3.27/init.js:108:436)
at b.extend.then.then.b.then (https://js.arcgis.com/3.27/init.js:111:152)
at Object.run (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/TaskSetting.js?wab_dv=2.11:53:36)
at Object.<anonymous> (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/Widget.js?wab_dv=2.11:359:35)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at k (https://js.arcgis.com/3.27/init.js:108:203)
at e.resolve (https://js.arcgis.com/3.27/init.js:110:280)
at Object.<anonymous> (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/Widget.js?wab_dv=2.11:425:15)
----------------------------------------
Error
at b.extend.then.then.b.then (https://js.arcgis.com/3.27/init.js:111:97)
at Object.run (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/TaskSetting.js?wab_dv=2.11:53:36)
at Object.<anonymous> (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/Widget.js?wab_dv=2.11:359:35)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)
at k (https://js.arcgis.com/3.27/init.js:108:203)
at e.resolve (https://js.arcgis.com/3.27/init.js:110:280)
at Object.<anonymous> (https://gis-gqfbcx1:3344/webappbuilder/apps/4/widgets/Query/Widget.js?wab_dv=2.11:425:15)
at https://js.arcgis.com/3.27/init.js:64:337
at l (https://js.arcgis.com/3.27/init.js:108:277)

Reply
0 Kudos
New Contributor II

Looks  like the error is on our side. ignore the above error.

Reply
0 Kudos