Can't hide Dashboard Group

Hi!
I'm struggling with hiding a group in the node-red dashboard. I want to hide the Finish Cocktail group if there are less than 2 ingredients in the table. I debugged the node, it sends the command to hide, but nothing happens. This is the code that decides if the group should be hidden or shown. It works but the group is always shown.

Any ideas?

var ingcnt = 0; // ingredient count
var nc = global.get("nc");  // cocktail object
if(nc == null)msg.payload = {group:{hide:["Finish_Cocktail"]}}; // hide group if the object doesn't exist
else
{
    for(var i = 0;i<8;i++)  // count ingredients
    {
        if(nc.id[i] !='')ingcnt++;
    }
    if(ingcnt > 1)  // show Finish Cocktail group if there are at least 2 ingredients
    {
        msg.payload = {group:{show:["Finish_Cocktail"]}};
    }
    else 
    {
         msg.payload = {group:{hide:["Finish_Cocktail"]}};  // if there are less then 2 ingredients hide the group
    }
}
return msg;

Bizarrely you are the second person to ask a question about Node-RED and cocktail ingredients recently. Is this coursework being set somewhere, if so where?

Nope, just a school project. :smiley:

Could you provide me with a link to that topic please.

Use the search and search for cocktail…

As per the README

Groups can be hidden and made visible via a msg like {group:{hide:["tab_name_group_name_with_underscores"],show:["tab_name_another_group"],focus:true}}

IE - they need the tab name as well as the group name... so it would be something like "Cocktail_Creation_Finish_Cocktail" - I'm guessing but you get the idea.

1 Like