Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Regular Contributor
Posts: 223
Registered: ‎05-01-2016

removing a dataview - SDK

[ Edited ]

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();
	});
});

 

Technical Evangelist
Posts: 816
Registered: ‎09-11-2015

Re: removing a dataview - SDK

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

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 223
Registered: ‎05-01-2016

Re: removing a dataview - SDK

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.

Regular Contributor
Posts: 223
Registered: ‎05-01-2016

Re: removing a dataview - SDK

[ Edited ]

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");
                         });
                     });

                 });

                });

            }
            

 

Regular Contributor
Posts: 223
Registered: ‎05-01-2016

Re: removing a dataview - SDK

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.

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.