Query string parameter to hide elements

I’m having a heck of a time figuring this one out.

I would like to add a querystring parameter that will hide (or not, based on the value) certain elements on the page via Javascript. I need to be able to change the visibility of certain on screen elements based on the user clicking an external link (that contains the proper querystring parameter) and depending on which link they click they get a slightly different experience.


I can’t capture it in JS because the querystring is rendered before any event I can utilize. Correct?

Any thoughts on how I can do this? It has to be using a querystring parameter.

Hi Devon,

You can show/hide elements on a click event using a script like this:
// for dealing with the adapters one by one
var adapters = this.parentView.control.adapters;

for (var index = 0; index < adapters.length; index++)
var adapter = adapters[index];

if (adapter)
var theName = adapter.name;
if (adapter.name === “theNameOfTheAdapterYouWantToHide”)
adapter.hidden = true;
else if (adapter.name === “theNameOfTheAdapterYouWantToShow”)
adapter.hidden = false;
// end

Or you can put several adapters in a group and show/hide them based on the group they belong to:
if (adapter.groupId === “theNameOfTheGroupYouWantToHide”)
adapter.hidden = true;
else if (adapter.groupId === “theNameOfTheGroupYouWantToShow”)
adapter.hidden = false;

I hope this helps,

1 Like

I appreciate that info, but hiding the elements isn’t the problem. It’s capturing the querystring to use it’s value to hide/not hide the elements.

Hey Devon,

If you use dundas.context.originalQueryString, you can access the query string.
To pull a specific value, you could then do something like this:

var queryString = dundas.context.originalQueryString;
var viewType = queryString["viewType"]



Thank you! I will give this a whirl.