WebGIS Discussions

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
Highlighted
Super Contributor
Posts: 301
Registered: ‎02-09-2016
Accepted Solution

Configure placeholder for the live search control in Portal 2016

Hi team,

 

Our client is using the live search function in the Portal. However, the default placeholder is simply just "...", so it is not meaningful.

 

Placeholder 1.png

 

We would like to replace this with more meaningful placeholder as followed

 

Placeholder 2.png

 however, we are not sure if it is possible.

 

Appreciate all suggestions and insights

 

Kind regards,

 

 

Highlighted
Anonymous
Posts: 0

Re: Configure placeholder for the live search control in Portal 2016

Hi Bob,

 

You can use this piece of code for the placeholder:

 

var searchField = Ext.getCmp($(".mwnt-live-search-combo")[0].id);
searchField.emptyText = "Enter something...";
searchField.reset();

But yeah, the above lines should be called when the livesearchcontrol is activated/initialized which is when the Search tab is clicked for the first time.

 

Regards,

Rohit Sinha

Highlighted
Super Contributor
Posts: 301
Registered: ‎02-09-2016

Re: Configure placeholder for the live search control in Portal 2016

Hi Rohit Sinha,

 

Yes, calling the script when the control is fully initialized is a tricky thing. I have a couple of ways replacing the text, but all of them require the control is initialized.

 

Is there any way that we listen when the control is initialized? for example, we can listen when the search tab in the toolbar is active?

 

Kind regards,

Highlighted
Technical Evangelist
Posts: 1,275
Registered: ‎09-11-2015

Re: Configure placeholder for the live search control in Portal 2016

Hi guys,

 

Any chance of using the mutation observer object?

http://community.hexagongeospatial.com/t5/Support-WebGIS/Customise-Data-Window-Functions/m-p/12416#M...

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Anonymous
Posts: 0

Re: Configure placeholder for the live search control in Portal 2016

Hi Bob,

 

Here you go, the complete snippet which listens to 'activate' of 'Search' Tab.

 

var searchTabElem = $.grep(Ext.getCmp('toolbar-menu-tabs').items.items, function(e){ return e.title== "Search"; });
var searchTab, executeOnceFlag = false;
if(searchTabElem.length !=0){
	console.log("Search Tab Panel Id: " + searchTabElem[0].id);
	searchTab = Ext.getCmp(searchTabElem[0].id);
	searchTab.addListener( "activate", function(e) {
		if (executeOnceFlag == false) {
			console.log("Activated");
			var searchField = Ext.getCmp($(".mwnt-live-search-combo")[0].id);
			searchField.emptyText = "Enter something...";
			searchField.reset();
			executeOnceFlag = true;
		}
	});
}
else
	console.log("Search Tab Panel not found");

Regards,

Rohit Sinha

Highlighted
Super Contributor
Posts: 301
Registered: ‎02-09-2016

Re: Configure placeholder for the live search control in Portal 2016

Thank you, Rohit Sinha. This very neat piece of code, I will test it right now. Appreciate your help.

 

Kind regards