11-16-2017 02:37 PM - edited 11-17-2017 08:52 AM
Below is the Add to Data View example that comes with the SDK. How can it be modified so a new tab is not added to the Data Window each time I run it? If the Query Name is the same i would like the tab instead be replaced with the query result. I would also like to be able to remove a DataView query from the Data Window.
var queryName = "DataView query"; $GP.queries.add({ featureClassId: "{http://www.intergraph.com/geomedia/gml}OM_USA_STATES", url: "http://demo.hexagongeospatial.com/GWM_WFS_NonTransactional/service.svc/get", definitionName: "WFS", queryName: queryName, addToLegend: false, filters: [{ operator: "OR", operands: [{ operator: "=", operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Oklahoma"] }, { operator: "=", operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Arkansas"] }, { operator: "=", operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Alabama"] }] }], }, function (result) { $GP.queries.find({ analysisId: result.analysisId, }, function (result2) { result2.analysis.addToDataView(); }); });
11-21-2017 04:29 AM
Hi Jane,
You would need to find out if the analysis already exists (through $GP.queries.find()) and if so, you would simply not call the addToDataView() in the callback.
Regarding removing existing analyses from the view programatically - there doesn't seem to be a support for such action in the current public API. You might want to post an idea to implement it.
Regards,
Jan
11-21-2017 07:49 AM
Thanks - i will check if a dataview has been added and then not add it if has been....but if user deletes the dataview tab but leaves analysis in legend i don't think i will be able to detect that the tab has been deleted.
11-21-2017 08:58 AM - edited 11-21-2017 09:00 AM
This isn't working - the dataview doesn't update unless it is a query to the same feature. I have 8 different queries all of which are given the name "Query" in the legend and they over write each other. The dataview tab updates if i run the same query twice but if i query Roads for example and get the roads dataview then if query Parcels, the parcles replace the roads in the legend but the dataview remains the one from Roads (unless i add to dataview in which case i have to dataview tabs (one for Roads and one for Parcels)
Code i use is below - i commened out the addtodataview and i run a different query to test so i a dataview tab has been created (not sure how to add logic to addtodataview based on setting of a variable)
function (result) { $GP.queries.find({ analysisId: result.analysisId, }, function (result2) { // result2.analysis.addToDataView(), $GP.legend.find({ name: qName }, function (result) { //alert(result.legendItems.length); if (result.legendItems && result.legendItems.length > 0) result.legendItems[0].set_name("Road Query"); }); }); }); }); }
11-27-2017 12:13 PM
i see how to check if the dataview was already added with this code
if (result.updated) { $GP.ui.info("Analysis updated"); return; }
but if the user deletes the dataview tab there is no way to know it is gone and it won't get recreated. As long as they don't delete the tab all is fine.