Query Widget Collapse Results Issue

870
3
Jump to solution
09-23-2019 06:45 AM
JasonStanton__GISP
Occasional Contributor

I am using WAB 2.13.  I have unchecked the "Expand the results list by default" item, but the results are still expanded by default.  Oddly enough the operation button that is displayed is the "Expand all".  Anyone have any ideas?

Jason

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jason,

   Seems like a widget bug. Here is my fix for that. This code goes in the SingleQueryResult.js file (lines 27 - 32 added and 40 modified).

      _createQueryResultItem: function(options, i) {
        var lastFeatureClass = '';
        var lastRelatedClass = '';
        var lastArrowData = '';
        if(i === this._featuresNum - 1){
          lastFeatureClass = ' ' + this._lastFeatureClass;
          lastRelatedClass = ' ' + this._lastRelatedClass;
          lastArrowData = 'data-lastArrow="true"';
        }
        var resultLayer = options.resultLayer;
        var feature = options.feature;
        var trClass = options.trClass;
        var popupTemplate2 = options.popupTemplate2;
        var relationships = options.relationships;
        var objectIdField = options.objectIdField;
        var url = options.url;
        var relationshipPopupTemplates = options.relationshipPopupTemplates;
        var shouldCreateSymbolNode = options.shouldCreateSymbolNode;
        var isWebMapShowRelatedRecordsEnabled = options.isWebMapShowRelatedRecordsEnabled;

        var attributes = feature && feature.attributes;
        if (!attributes) {
          return;
        }
        var title = this._getPopupTitle(popupTemplate2, feature);
        //create PopupRenderer
        var expClass;
        if(html.hasClass(this.resultsTbody, 'expanded')){
          expClass = 'expanded';
        }else{
          expClass = 'folded';
        }

        var strItem = '<tr role="button" tabindex="0" ' +
          'class="jimu-table-row jimu-table-row-separator query-result-item' + lastFeatureClass + '" ' +
          ' cellpadding="0" cellspacing="0"><td>' +
          '<table class="query-result-item-table">' +
          '<tbody>' +
          '<tr>' +
          '<td class="symbol-td"></td><td class="popup-td '+ expClass +'">' +
          '<div class="popup-title-container">' +
          '<div class="popup-title">' + title + '</div>' +
          '<div role="button" tabindex="0" aria-label="' + this.nls.collapse + '" ' + lastArrowData +
          ' class="popup-title-icon"></div></div>' +
          '<div class="popup-content"></div>' +
          '</td>' +
          '</tr>' +
          '</tbody>' +
          '</table>' +
          '</td></tr>';
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Jason,

   Seems like a widget bug. Here is my fix for that. This code goes in the SingleQueryResult.js file (lines 27 - 32 added and 40 modified).

      _createQueryResultItem: function(options, i) {
        var lastFeatureClass = '';
        var lastRelatedClass = '';
        var lastArrowData = '';
        if(i === this._featuresNum - 1){
          lastFeatureClass = ' ' + this._lastFeatureClass;
          lastRelatedClass = ' ' + this._lastRelatedClass;
          lastArrowData = 'data-lastArrow="true"';
        }
        var resultLayer = options.resultLayer;
        var feature = options.feature;
        var trClass = options.trClass;
        var popupTemplate2 = options.popupTemplate2;
        var relationships = options.relationships;
        var objectIdField = options.objectIdField;
        var url = options.url;
        var relationshipPopupTemplates = options.relationshipPopupTemplates;
        var shouldCreateSymbolNode = options.shouldCreateSymbolNode;
        var isWebMapShowRelatedRecordsEnabled = options.isWebMapShowRelatedRecordsEnabled;

        var attributes = feature && feature.attributes;
        if (!attributes) {
          return;
        }
        var title = this._getPopupTitle(popupTemplate2, feature);
        //create PopupRenderer
        var expClass;
        if(html.hasClass(this.resultsTbody, 'expanded')){
          expClass = 'expanded';
        }else{
          expClass = 'folded';
        }

        var strItem = '<tr role="button" tabindex="0" ' +
          'class="jimu-table-row jimu-table-row-separator query-result-item' + lastFeatureClass + '" ' +
          ' cellpadding="0" cellspacing="0"><td>' +
          '<table class="query-result-item-table">' +
          '<tbody>' +
          '<tr>' +
          '<td class="symbol-td"></td><td class="popup-td '+ expClass +'">' +
          '<div class="popup-title-container">' +
          '<div class="popup-title">' + title + '</div>' +
          '<div role="button" tabindex="0" aria-label="' + this.nls.collapse + '" ' + lastArrowData +
          ' class="popup-title-icon"></div></div>' +
          '<div class="popup-content"></div>' +
          '</td>' +
          '</tr>' +
          '</tbody>' +
          '</table>' +
          '</td></tr>';
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
JasonStanton__GISP
Occasional Contributor

Thanks again that worked!  Point of note -  the adds are lines 26-31.

0 Kudos
MikeWeiner
New Contributor

I'm fairly new to web appbuilder.  We added the above code which seems to fix the icon starting on the right setting but our results keep showing up as expanded.  No matter if we uncheck the box or not.  We want the results to show up as collapsed and allow the user to expand the result they want.

Also the change to the code in the answer does not specify which copy of the SingleResultQuery.js to change.  I found four different copies of it.

Thank you.

0 Kudos