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.
Solved! Go to Solution.
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"){
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
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?
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.
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"];
}
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"){
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"];
}
Great don't forget to mark this question as answered.
If we set custom result, it will not support. get original feature class name by "this.currentAttrs.query.resultLayer.infoTemplate.info['title']"
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.