show/hide a group of elements thru script

Hi,

I’d like to have several groups of elements on the same layer but to show only one at the time. The idea is to have only one layer as there is no way to have parameter values passed from one layer to another when they are accessed in a random way chosen by the end-user.
My use case is :

  • several forms in the same Dashboard
  • the end user is the one choosing in what order he/she fills the forms, and can edit them several times before validating the whole data.
  • once all the forms have been filled, values taken from those forms have to be passed to one stored procedure only once.
  • no storage can be done elsewhere but in the Dashboard itself as long as the different forms are not filled.

My first thought was to use layers, but for now I haven’t found a way to make them communicate, each of them can be invoked one by one, but I haven’t found a way to share values between several layers.

That’s why I thought about grouping elements, as a groups can be hidden, but all of them are on the same layer. what I’d like to be able to do is to show/hide them thru script depending on which button the end user clicked on. But I haven’t found a way to get the groups of elements thru script.

Thanks in advance for your suggestions,
Olivier Romero

Hello @romero.olivier,

Regarding the layers, you can hide and show a specific layer by number or name:
//number
this.baseViewService.currentView.layerAdapters[0].hidden = true;
//name
var myView = this.baseViewService.currentView;
var myLayer = myView.layerAdapters.toEnumerable().first(function (la) {
return la.name === “Layer1”;
});
myLayer.hidden = true;
If you have specific requirements regarding the layer functionality you can add some functions and change the position, order etc.

Dear Costin,
Thank you I will dig for trying to get the parameters linked to specific layers, if I can manage to access them thru script when the view is set to another layer, in order to get/set the different values, then this could be a solution. Even if it would be far easier if I could access a group thru script, which I haven’t found how to yet.
Olivier

Hi All,

For those who may be interested in doing the same thing, thanks to Jay from the Dundas’s support who suggested to use the groupId instead of trying to hide the group itself directly, using that kind of script on a button’s click event works:

var adapters = this.parentView.control.adapters;

for (var index = 0; index < adapters.length; index++)
{
var adapter = adapters[index];
if (adapter)
{
if (adapter.groupId === “the_group_you_want_to_show_Id”)
{
//show the items having the same groupId
adapter.hidden = false;
}
else
{
//hide all the other items that are not in the targeted group
adapter.hidden = true;
}
}
}

Of course you can add a group that is never hidden like a “menu” (I’m not referring to the “menu layer”, everything should be on the same layer, for this to work) as long as all the “menu” items have the same groupId (which is the name you give to the group thru the graphical interface). For this you just need to add an “else if” condition dealing with the corresponding groupId.

With this approach there is no need to deal with layers. Maybe it’s not the best one, but, for what I’m aiming to build, it works.

Have a nice day,
Olivier

2 Likes