Select to view content in your preferred language

Query widget - spatial filter and operational layer issue

9045
23
Jump to solution
02-06-2015 08:58 AM
VenusScott
Frequent Contributor

Using my local install of WAB I've configured the Query widget to select by Use spatial filter to limit the features, Only features touching a user defined area, and Add the result as operational layer.

I also want the user to be able to export the operational layer as a CSV. I haven't been able to get the operational layer to display nor do I have the option to export anything as CSV?

I do have the Attribute Table configured to Allow exporting to CSV.

Anyone else have this issue?

23 Replies
JoshWhite
Honored Contributor

I may not have put this in the right location but I didn't notice a change.  It still tries to open an html file first in IE 11 and adding csv doesn't fix the issue.  I did test in Chrome and it immediately creates a csv file for export and the resulting file is created without issue.  I placed this in

...\arcgis-web-appbuilder-1.1\client\stemapp\widgets\AttributeTable\Widget.js

UPDATE:  When I put this in ...\<appname>\widgets\AttributeTable\Widget.js it does appear to work in IE 11

Josh White, AICP
Principal Planner

City of Arkansas City
0 Kudos
ZeZhengLi
Esri Contributor

Josh,

     I forgot that we are not in the same version, so the `widget.js` need other codes.

_isIE11: function() {
        var iev = 0;
        var ieold = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
        var trident = !!navigator.userAgent.match(/Trident\/7.0/);
        var rv = navigator.userAgent.indexOf("rv:11.0");


        if (ieold) {
          iev = Number(RegExp.$1);
        }
        if (navigator.appVersion.indexOf("MSIE 10") !== -1) {
          iev = 10;
        }
        if (trident && rv !== -1) {
          iev = 11;
        }


        return iev === 11;
      },


      _isEdge: function() {
        return /Edge\/12/.test(navigator.userAgent);
      },


      _getDownloadUrl: function(text) {
        var BOM = "\uFEFF";
        // Add BOM to text for open in excel correctly
        if (window.Blob && window.URL && window.URL.createObjectURL) {
          var csvData = new Blob([BOM + text], { type: 'text/csv' });
          return URL.createObjectURL(csvData);
        } else {
          return 'data:attachment/csv;charset=utf-8,' + BOM + encodeURIComponent(text);
        }
      },


      download: function(filename, text) {
        if (has('ie') && has('ie') < 10) {
          // has module unable identify ie11 and Edge
          var oWin = window.top.open("about:blank", "_blank");
          oWin.document.write(text);
          oWin.document.close();
          oWin.document.execCommand('SaveAs', true, filename);
          oWin.close();
        }else if (has("ie") === 10 || this._isIE11() || this._isEdge()) {
          var BOM = "\uFEFF";
          var csvData = new Blob([BOM + text], { type: 'text/csv' });
          navigator.msSaveBlob(csvData, filename);
        } else {
          var link = html.create("a", {
            href: this._getDownloadUrl(text),
            target: '_blank',
            download: filename
          }, this.domNode);
          if (has('safari')) {
            // # First create an event
            var click_ev = document.createEvent("MouseEvents");
            // # initialize the event
            click_ev.initEvent("click", true /* bubble */ , true /* cancelable */ );
            // # trigger the evevnt/
            link.dispatchEvent(click_ev);
          } else {
            link.click();
          }


          html.destroy(link);
        }
      },

     In the `exportToCSV` function you need to use `params.title` instead of `params.name`.

     For you mentioned that you didn't notice a change, I think you need to restart the node server and try again.

JoshWhite
Honored Contributor

Thanks, I think I may have to bite the bullet and jump to 1.2, it sounds as if many of the widgets are getting updated so I may as well do it. 

Josh White, AICP
Principal Planner

City of Arkansas City
ZeZhengLi
Esri Contributor

Venus,

This  is as designed. For now there has no way to update layers if users has configured it.

We are going to let AttributeTable synchronous with map in next release.