-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datasource not loading in experience builder preview. #193
Comments
For performance reasons, the data source is created on demand by the widget in runtime. Could you use the to create the data source? |
I tried using the createDataSource method from the DataSourceManager instance but I get an error saying that the datasource couldn't be created.
|
The child data sources can't be created directly in the DatasourceManager, can you try the ? |
Can I try what? |
|
I dont want to use the DataSourceComponent because I want to pull all the datasources from the map widget selected. I did manage to get my code working by using jimuLayerView.createLayerDataSource() but I don't see this method documented by esri. I would like to use the DataSourceManager.getInstance().createDataSource(jimuLayerView.layerDataSourceId) since it's documented but I can't seem to get it to work. Do you know why using this method doesn't work? |
The reason why Creating all data sources from a map is not a good practice; creating too many data sources may cause performance issues. |
What would be the proper way of creating child data sources? Should I continue to use the jimuLayerView.createLayerDataSource() method? Will the DataSourceManager be capable of creating child data sources in the future? |
I am working on a custom widget and my code works while in the builder mode of experience builder. However, whenever I preview my widget, the datasource is undefined. Is this by design? What causes this?
I appreiciate any help.
`import {
DataSource,
DataSourceManager,
React,
type AllWidgetProps,
} from "jimu-core";
import { type IMConfig } from "../config";
import { JimuLayerView, JimuMapView, JimuMapViewComponent } from "jimu-arcgis";
import { MouseEvent, useState } from "react";
import { Dropdown, DropdownButton, DropdownItem, DropdownMenu } from "jimu-ui";
import ConditionController from "./conditionController";
import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js";
const Widget = (props: AllWidgetProps) => {
const [dataSources, setDataSources] = useState<DataSource[]>([]);
const [selectedDataSource, setSelectedDataSource] = useState({
dataSource: null,
schema: null,
});
function onActiveViewChange(activeView: JimuMapView) {
if (activeView) {
activeView.whenAllJimuLayerViewLoaded().then((jimuLayerViews) => {
const dataSources = Object.values(jimuLayerViews).map((jimuLayerView) =>
jimuLayerView.getLayerDataSource()
);
}
function handleDataSourceSelection(mouseEvent: MouseEvent<any, MouseEvent>) {
const ds = dataSources.find(
(ds) => ds.id === (mouseEvent.target as HTMLInputElement).value
);
}
return (
QueryBuilder Widget
);
};`
The text was updated successfully, but these errors were encountered: