Extracting CSV Data Without Saving a File

2190
13
11-23-2016 12:58 PM
WilliamMiller4
Occasional Contributor II

Hello,

I'm trying to create mailing labels for selected parcels. I'd like to take values from the CSV that WAB can generate (in the Attribute Table widget), get a string from the result, parse it and add the results to a pdf generator. I found the CSVUtils.js, in particular the exports._createCSVStr function, but I'm having trouble implementing it. Has anyone else used this function? Please let me know how you got the parameters (datas, columns) to use in the function. Any help is much appreciated. Thank you for your time.

William

0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

William,

   What part are you struggling with? The function take a datas object with is an array of objects with key and value (i.e. field1: "blah blah") and columns which is a array of strings that represent the column names.

0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,

I'm not sure how to create the arrays with the data I want to include.

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

   I am struggling to see what you are struggling with. The datas object with is an array of objects with key and value (i.e. field1: "blah blah").

I guess I can provide a more detailed example:

var data = [
  {
    First: "William",
    Last: "Miller",
    Gender: "Male"
  }, {
    First: "Robert",
    Last: "Scheitlin",
    Gender: "Male"
  }
];‍‍‍‍‍‍
0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,

Sorry for being so vague. Say I use the By Shape tab of your Enhanced Search widget and create a circle that encompasses multiple properties. In the Results tab, I click the ellipses button and View in Attribute Table. How would I access the data that is now displayed in the table?

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

   The table would just be displaying the attributes of the graphics associated with the search results. So you would get a reference to the search layer and loop through its graphics and get the attributes property of each graphic and add it to an array and that now becomes your datas array.

0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,

How do I get a reference to the search layer?

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

this.map.getLayer("some layer id");

0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,


What would the "some layer id" be for the search layer?

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

   It would be what you see in the attribute tables widgets tab title.

0 Kudos