Select to view content in your preferred language

Web App Builder - How to limit fields in "export to CSV" option in query widget?

5422
16
Jump to solution
05-31-2017 09:24 AM
KyleSchwizer
Occasional Contributor

I am trying to limit the fields exported in the "export to CSV" option for the query widget. I would like to just limit the field exported to the same fields that are within our popups for our parcels.  I know i might have to dive into the code in the CSV.Utils.js for the application. Any direction or help to lead me to a work around would be great. I am working with Web App Builder for Developers 2.4.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Kyle,

   The layer.id will not be 5 it will be something like "graphicsLayer4". I would use the layer.name instead:

if (layer.name === "Owner Parcels _Query Result"){

View solution in original post

16 Replies
RobertScheitlin__GISP
MVP Emeritus

Kyle,

   In the SingleQueryResult.js file find this line

featureSet.fields = lang.clone(layer.fields);

This is where the fields that are exported are specified. You could modify the available field here before it is passed to the ExportToCSV.js

KyleSchwizer
Occasional Contributor

Robert,

So I have been able to get result that i am looking for, however it is being applied to all the layers within my query widget.  I have both parcels and address points being used in my query widget  When i go to export out address points results as a CSV the results will only list the "PIN" field. Which in my address point data is not a valid field.

        layer.fields = ["PIN"]
        featureSet.fields = lang.clone(layer.fields);

Is there a way that i can call the Layer's popup configuration from the web map as the fields that should be exported?  So instead of doing the above code, limit the featureSet.fields to the web map popup that is specified in the query configuration dialogue box? 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kyle,

   What you are asking for would be difficult. The easier way would be to check which layer id you are working with and apply the code change based on the proper layer or not.

0 Kudos
KyleSchwizer
Occasional Contributor

Robert,

This sounds like a better way of accomplishing what I would like to do. I have the if else statement created but I am having trouble getting the layerID from the layer variable. Should i create another var that gets the layer info from the query.resultLayer? It is probably really simply what i am tyring to do but i am somewhat new to custom coding.

  var layer = this.currentAttrs.query.resultLayer;
        var featureSet = new FeatureSet();
        if (layer.id===5){
          layer.fields = ["PIN"];
        } else if (layer.id===1) {
          layer.fields = ["ADDRESS"];
        }
        ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kyle,

   The layer.id will not be 5 it will be something like "graphicsLayer4". I would use the layer.name instead:

if (layer.name === "Owner Parcels _Query Result"){

KyleSchwizer
Occasional Contributor

Robert,

It worked perfectly! Now just have to go in and add the fields i would like.  Thank you so much for sharing your wealth of knowledge.

_getFeatureSet: function() {
        var layer = this.currentAttrs.query.resultLayer;
        var featureSet = new FeatureSet();
        if (layer.name==="Parcel _Query Result"){
          layer.fields = ["PIN"];
        } else if (layer.name==="Address _Query Result") {
          layer.fields = ["ADDRESS"];
        }
RobertScheitlin__GISP
MVP Emeritus

Great don't forget to mark this question as answered.

0 Kudos
RamakrishnaDesetti
New Contributor

If we set custom result, it will not support. get original feature class name by "this.currentAttrs.query.resultLayer.infoTemplate.info['title']"

0 Kudos
KyleSchwizer
Occasional Contributor

Robert,

If i wanted to accomplish the same task in your Enhanced Search widget, how would the layer.name string be formatted? It was easy to figure out how the layer.name was formatted in the Query widget but with your Enhanced Search widget i am having a little bit more difficulty. 

0 Kudos