Is it possible to use two different datasources in the same custom widget with DataSourceSelector?

378
4
Jump to solution
06-03-2021 05:05 AM
PärÅman
New Contributor II

Trying to add another datasource using DataSourceSelector in settings.tsx only change synchronized with the other one, as they both user 

 

useDataSources={this.props.useDataSources}

 

How do I make it happen?

0 Kudos
1 Solution

Accepted Solutions
ToddJacobus
New Contributor II

Hi,

I'm not sure if this is what you're asking, but the DataSourceSelector component has a isMultiple prop that, when set to true, will allow the user to configure multiple data sources.  There's no way you are expected to know this since the DataSourceSelector component is not documented anywhere.  I discovered this after ~3 days of hacking through work-arounds.

Cheers

View solution in original post

4 Replies
ToddJacobus
New Contributor II

Hi,

I'm not sure if this is what you're asking, but the DataSourceSelector component has a isMultiple prop that, when set to true, will allow the user to configure multiple data sources.  There's no way you are expected to know this since the DataSourceSelector component is not documented anywhere.  I discovered this after ~3 days of hacking through work-arounds.

Cheers

View solution in original post

by Anonymous User
Not applicable

Thanks, that's really great.  How in the world did you find that given that the documentation links are broken?

It seems like I have to use a separate DataSourceComponent for each DataSource configured in the settings page - is that correct?

 

0 Kudos
ToddJacobus
New Contributor II

Hah, I finally found someone's implementation of the component where they pass in a isMultiple prop, in code published on Stack Overflow.  I don't have the link handy, though, sorry.  But, you can also see ESRI's own implementation of it in the Experience Builder source code.  For example, in ...\client\dist\widgets\common\text\src\setting\setting.tsx. 

And, yes, I'm mapping over this.props.useDataSources and passing each "useDataSource" to a DataSourceComponent.  This works for me, since I'm summarizing data from each data source, so I use the callback function to pass actual DataSource objects to a summary table.  I'm not sure if this is "correct", but it seems to work.  Hope this helps.

Cheers

PärÅman
New Contributor II

Yes it helped. And yes, I find the documentation being somewhat sparse, and in need for another go-around in the Google index carousel.

0 Kudos