Select to view content in your preferred language

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

3916
6
Jump to solution
06-03-2021 05:05 AM
Labels (1)
PärÅman
Emerging Contributor

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
Emerging Contributor

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

6 Replies
ToddJacobus
Emerging Contributor

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

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
Emerging Contributor

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

JamalWest2
Regular Contributor

Were you able to utilize this to use more than 2 data sources? Right now it is only letting me select 2.

0 Kudos
Craig_Tobias
New Contributor

Hello,  would you be able to share any examples you have that show your usage of the isMultiple prop?  I have been working through how to use it, though it seems to not work for me.  I found this bit of documentation for it, https://developers.arcgis.com/experience-builder/storybook/?path=/story/components-jimu-ui-advanced-... , which shows it works.  Though I have tried putting the isMultiple into the List Widget itself and nothing happens.  Any recommendations?

Thanks

0 Kudos
PärÅman
Emerging Contributor

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