Hi, I am building a custom widget that replicates the main features in the zone lookup instant app with the additional capabilities of selecting target zones using multiple layers or locators to return features based on a spatial intersection, or layer sources to return features using attribute filter.
The custom widget is triggered by actions from the Search, Map, and Table widgets based on record selection changes. Everything is updating properly in the Map widget but I am unable to get the query that is applied to the target zones from clearing to return all features in the table widget. I created this function to access the datasource being displayed in the Map and Table to update the query parameters to show all features, but the table widget data does on update.
I have tried the using the updateQueryParams() method for the data source and passing the sql query to return all features and passed it the widget id of the table and all other widgets that use the data source but for some reason the table will not refresh or update like the map.
Are there some limitations with the updateQueryParams function that will not extend to the table widget?
Is there a way to force the table widget to refresh?
const handleClearResults = async () => {
console.log("handling clear results")
let targetDsIds = props.config['zones']['target']
const dsManager = DataSourceManager.getInstance();
const appConfig = getAppStore().getState().appConfig
const widgets = appConfig.widgets
targetDsIds.map((targetId : string) => {
console.log("Target ID: ", targetId)
let targetDs: FeatureLayerDataSource = dsManager.getDataSource(targetId) as FeatureLayerDataSource;
console.log("Target ds: ", targetDs)
let schema = targetDs?.getSchema()
let title = targetDs.getLabel()
//console.log("schema", )
setNumResults(0)
setResults(prev => ({
...prev,
[title]: 0
}))
if(schema){
const queryParams: SqlQueryParams = {
where: '1=1',
//where: `${Object.keys(schema.fields)[0]} IS NOT NULL`
}
Object.entries(widgets).forEach(([widgetId, widgetConfig]) => {
const widgetDataSources = widgetConfig.useDataSources || [];
const hasDataSource = widgetDataSources.some((ds) => ds.dataSourceId === targetId);
if (hasDataSource) {
console.log("updating data source for: ", widgetConfig.label)
targetDs.updateQueryParams(queryParams, widgetId);
}
// console.log("widgetConfig.manifest.name: ", widgetConfig.manifest.name)
// if (widgetConfig.manifest.name === "table"){
// let tableId = widgetConfig.id
// getAppStore().dispatch({type:""})
// }
});
//targetDs.updateQueryParams(queryParams, props.id)
//targetDs.clearRecords()
targetDs.layer.load().then(() =>{
console.log("layer loaded")
})
console.log("updated datasource: ", targetDs)
targetDs.clearSelection()
console.log("target features cleared: ", targetDs.getSelectedRecords().length)
}
toggleMapLayers(undefined, true)
})
}