addData Widget in API javascript 4.12 ?

1732
4
Jump to solution
09-23-2019 01:52 PM
JUBJUB
by
New Contributor II

In the Portal Viewer, we can add data from portal, from url, or from local file.

In WAB developper edition, there is a widget called "addData" : https://developers.arcgis.com/web-appbuilder/guide/widget-add-data.htm

I don't find a way to do the same in API 4.12. Is there a way to do that ?

Thanks

0 Kudos
1 Solution

Accepted Solutions
BenElan
Esri Contributor

Hi Jub, I am unaware of a built in way to allow the user to add items from Portal. However, using the service url you can try to build it yourself. I can create a sample for this

Edit: 

Here is the sample: https://codepen.io/benesri/pen/QWLYRoK?editors=1000 

 

Note that there is no error handling and it assumes everything is a FeatureLayer, but it's something that you can build on

View solution in original post

4 Replies
BenElan
Esri Contributor

This is a sample in 3x 

In this thread Munachiso was able to convert the sample to 4x

Here is the github for the 4x version 

 You do need AGOL or Portal for this to work. Also you may need the resource proxy to remedy any CORS errors you may get. This sample is based on the 3.x, so a lot of the code from that sample is the same with some changes for 4.x.

- Munachiso

JUBJUB
by
New Contributor II

Thanks, this is a good method to add data from local files. An other way to upload data is : Create a FeatureLayer with client-side graphics | ArcGIS API for JavaScript 4.12 

But is there a way in 4x to interact with Portal content ? I mean, is it possible the end-user to load data from Portal (like in Portal Viewer or WAB addData widget) ?

Thanks

0 Kudos
BenElan
Esri Contributor

Hi Jub, I am unaware of a built in way to allow the user to add items from Portal. However, using the service url you can try to build it yourself. I can create a sample for this

Edit: 

Here is the sample: https://codepen.io/benesri/pen/QWLYRoK?editors=1000 

 

Note that there is no error handling and it assumes everything is a FeatureLayer, but it's something that you can build on

JUBJUB
by
New Contributor II

Thanks Ben, this sample works perfectly

0 Kudos