Hexagon Geospatial
MENU

Support WebGIS

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Regular Contributor
Posts: 184
Registered: ‎10-26-2015

Customise Data Window Functions

Hi,

I need to understand whether its possible to remove the following functions from the data window in Geospatial Portal:

 

Remove all features from the database

Remove selected features from the database

Export all features to a CSV file

Export selected features

 

Thanks for any replies!

 

Colin

Super Contributor
Posts: 285
Registered: ‎02-09-2016

Re: Customise Data Window Functions

Hi Colin,

 

We did thought about fixing the data window in our last portal project. We could not find any offical way to re-configure functions in the Data window.

 

One way is quite feasible is that you can use Extjs api to locate these buttons on the Data window and then hide them.

 

Kind regards,

Regular Contributor
Posts: 184
Registered: ‎10-26-2015

Re: Customise Data Window Functions

Hi Bob,

Could you help me to understand how to use ExtJS API to locate the buttons and hide them?

Do you have any examples you can share?

 

Thanks,

Colin

Super Contributor
Posts: 285
Registered: ‎02-09-2016

Re: Customise Data Window Functions

HI Colin,

 

Here is an example, this way may not be recommended, but this is how we locate buttons in Data window and invoke them.

 

In geospatial portal EP05 2015, we have an issue with data window that retains selected instance from previous session. So when a user launches a new session, we somehow need to invoke 'clear clipboard' button on the data window

 

 

function TriggerClearClipBoardforEP05()
	{
		
		var datawindow = Ext.getCmp("DataWindowExt");
		
		if (datawindow != null)  //start drilling down its components
		{ 
			var itemLength = datawindow.items.length;
			
			if (itemLength > 1)
			{
				var tabPanel = datawindow.items.items[1];
				
				if (tabPanel != null)
				{
					var activeTab = tabPanel.items.items[0];
					
					if (activeTab != null)
					{
						var clearBtn = activeTab.buttons[0];
						
						if (clearBtn != null)
						{
						    console.log('---> Find Clear Clipboard button, triggering its click function...');
							
							clearBtn.el.dom.click(); //trigger clear button
							
							return true;
						}
					}
				}
			}
			else
			    console.log("Fail to get the 'Clear Clipboard button'...", null);
		}
		return false;		
	}
	
	
$GP.ready(function () {
			
	   setTimeout(function()
	   {
		TriggerClearClipBoardforEP05();  //need to delay, so the data window can be fully initialized
	   },1000);
	
		
	});

 

Hopefully, it helps. Please be carefully with the timing when you call this function in order to make sure that the data window is created.

 

Kind regards,

 

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

Re: Customise Data Window Functions

[ Edited ]

Since the buttons are created dynamically, for each new data window tab I would personally go jQuery way and watch the DOM for newly created elements. Each time a button is created in the DOM, I would find it, fint its parent table element and hide it. Something like this:

 

$('body').on('DOMNodeInserted', 'button', function (e) {
    // button added to DOM
    // check if it's the button we don't want to display
    if(e.target && e.target.className == "wc_data_view_add_selected_to_clipboard")
    {
        // find closest parent TABLE element and hide it
        $(e.target).closest("table").css( "display", "none");

        // or probably better approach is to directly delete them from DOM
        $(e.target).closest("table").remove();
    }
});

This is not tested but hopefully shows my idea.

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 49
Registered: ‎10-27-2015

Re: Customise Data Window Functions

Hi Jan,

 

where do I need to put this code snippet?

 

I tried wrapping it in Sys.Application.add_init(function() {}); in Map.config.js or $GP.ready(function () {}) in custom.js but the event is never fired.

 

Thank you

Denis

 

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

Re: Customise Data Window Functions

Hi Denis,

 

This was rather a pseudo-code following my idea. I actually didn't test it Smiley Embarassed

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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

Re: Customise Data Window Functions

Also, it looks like the DOMNodeInserted is obsolete and isn't supported by modern browsers. Here's a replacement:

http://gabrieleromanato.name/jquery-detecting-new-elements-with-the-mutationobserver-object/

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Technical Evangelist
Posts: 859
Registered: ‎09-11-2015

Re: Customise Data Window Functions

[ Edited ]

Ok, I've quickly tested that and this code seems to be working. But it likely requires some optimizations and error-checking.

 

window.onload = function() {

console.log("registering events");
// The node to be monitored
var target = $( "body" )[0];

// Create an observer instance
var observer = new MutationObserver(function( mutations ) {
  mutations.forEach(function( mutation ) {
    var newNodes = mutation.addedNodes; // DOM NodeList
    if( newNodes !== null ) { // If there are new nodes added
    	var $nodes = $( newNodes ); // jQuery set
    	$nodes.each(function() {
         var $node = $( this );
         // TODO: Add some clever logic here for optimization purposes!
         $(".wc_data_view_add_selected_to_clipboard").closest("table").remove();
         $(".wc_data_view_export_all_to_CSV").closest("table").remove();
         $(".wc_data_view_export_selected_to_CSV").closest("table").remove();
    	});
    }
  });    
});

// Configuration of the observer:
var config = { 
	attributes: true,
	childList: true, 
	characterData: true 
};
 
// Pass in the target node, as well as the observer options
observer.observe(target, config);
 
// Later, you can stop observing
// observer.disconnect();
};

 

 

Place it into e.g. js\Custom.js file and add a ScriptReference it in the ASPX page:

 

    <asp:ScriptManager runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true">
        <Scripts>
             ...
            <asp:ScriptReference Path="js/Custom.js" />
        </Scripts>
    </asp:ScriptManager>

 

And don't forget to download and reference jQuery:

http://community.hexagongeospatial.com/t5/Support-WebGIS/Geospatial-Portal-Forms-Authentication-time...

 

Works fine for me:

Untitled.png

 

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 49
Registered: ‎10-27-2015

Re: Customise Data Window Functions

Hi Jan,

 

it doesn't work in IE. Which browser did you use?

 

Thanks,

Denis

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.