Export featureTable to CSV

6693
11
04-21-2016 09:17 AM
DonCaviness
New Contributor III

I'm using the featureTable dijit in my application. I am able to populate the table based on different featureLayers in the map. I would like to be able to export the table to a CSV file the user can download.  The number of features in table can be any where from less than 10 to upwards of 10,000.  Is there any samples or known ways to export the featureTable to CSV?  I have tried several things but have been unsuccessful.

0 Kudos
11 Replies
YueWu1
by
Regular Contributor

Hi Don,

Here is a sample shows how to Extract Data from a map service: :"http://developers.arcgis.com/javascript/sandbox/sandbox.html?sample=gp_clipasync"

Basically, you need to use "esri/tasks/Geoprocessor". which means you have to create your own geoprocessing tool and then publish as gp service.

For more information, you can take a look about this online documentation about "geoprocessing specifically in ArcGIS Server 10.2 version" http://resources.arcgis.com/en/help/main/10.2/index.html#//002s00000002000000

Or 10.3 ArcGIS Server: http://server.arcgis.com/en/server/10.3/publish-services/windows/a-quick-tour-of-publishing-a-geopro...

Hope this can help.

DonCaviness
New Contributor III

Thanks but this is not a path I'm interesting in going down.  I'm not looking to clip and ship the data.  I'm just wanting to export out the featureTable to a CSV file. In my application I have a featureTable similar to the table in this example Using FeatureTable | ArcGIS API for JavaScript .  I do not have my application formatted like this example, but I am using the featureTable dijit.

0 Kudos
YueWu1
by
Regular Contributor

Hi Don,

You have to write code to implement this new function. Currently FeatureTable widget doesn't have csv export function.

Essentially, you need to get all the data that loaded in dgrid and export to csv file.

GitHub - kfranqueiro/dojo-smore: Dojo stores are great! Here, have s'more.

0 Kudos
DonCaviness
New Contributor III

Looking at that repo, I'm have no idea how to even begin to try to implement it in my application.  There isn't a very clear example there.  Any suggestion?

0 Kudos
DonCaviness
New Contributor III

Yes that is exactly what I'm attempting to do.  I was aware the featureTable does not have the export capability (would be a fantastic addition) and that I would need to write a custom piece.  That is what my original question was for. I will look at the sample in the link you posted to see if that is something that can work in my application.

In the mean time, has anyone been able to figure out a way to do this?

0 Kudos
ReneRubalcava
Frequent Contributor

Shamelessly borrowed code from here Use JavaScript to Export Your Data as CSV - Chris Grimes

http://codepen.io/odoe/pen/rerdrm

Only exports what the table has downloaded though and only the raw data. Could tweak to export using column data probably.

JamesOsundwa
New Contributor III

Hi Rene Rubalcava this sample that you put together is precisely what I need but it doesn't seem to work for me :(  I simply took it exactly as-is and put it in a HTML...no error in my console but no download either...

0 Kudos
YueWu1
by
Regular Contributor

Hi Don,

Based on Rene Rubalcava​ 's code, here I combine this new Export CSV function within the dropdown menu in our FeatureTable sample. You can try view this live demo http://jsbin.com/bubutucoqa/edit?html,output​ using Chrome browser.

DonCaviness
New Contributor III

Thanks guys! I knew there had to be  a simplier way of doing this.  I had come up with a solution but it was a bit hacky, this is much cleaner. I will give it a try in my app.

Yue, you said to view the live demo in Chrome.  Why is that? Will the functionality not work in other browsers or is it just jsbin?

0 Kudos