Question

Close the navigation sidebar programmatically.

Hey guys,

 

How can I close the navigation sidebar programmatically?

 

I'm trying to implement the same behavior that happens when you press the button indicated in the image below, making the main navigation bar to hide, so I can give users more width space for the section form screen without them to having to do that.

 

 

I tried with something like this based on what I saw somewhere in the code, but is not working for me.
 

const closeSidebarRequest = { 
	type: "crt.NavigationPanelChangeVisibleRequest", 
	$context: request.$context, 
	isVisible: false 
	};
 
await request.$context.executeRequest(closeSidebarRequest);

 

 

Thanks!

 

 

 

Like 0

Like

3 comments

Hello Andres,
Thank you for your question.

I am a bit confused as I do not understand the business need for this customization. Could you please clarify if this is a necessity? From my point of view, this feature is a bit of an overkill. First of all, there is already a button to control whether or not the navbar is shown. If the user wants to have control over seeing the navbar, and you implement an additional way to do so (for example, another button), then you will have two buttons for the same task. Secondly, I think that calling crt.NavigationPanelChangeVisibleRequest will not help.


I will be glad to assist you if you need to implement this functionality. I am curious about how you plan to control the visibility of the navbar.

Hi Yevhenii, 


In our case users are mostly working on one section and do not move from there. I'd like to hide the navbar by default when they enter to creatio and as you said, in case they need to navigate outside of that section they can open it with the button thats already there.

 

Is there any way to hide the navbar by default for all users? That is what I'm trying to accomplish, not another button.

 

Thanks,

Andres

Hello Andres,

I have come up with a solution that might help. When the user navigates to the application, the left panel is hidden/collapsed by default. If the user wants the left panel to be visible, they can click on the top-left button to show the navigation panel. To do this, I replaced the MainShell schema with the following code:
 

define("MainShell", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
   return {
       viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
       ]/**SCHEMA_VIEW_CONFIG_DIFF*/,
       viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
           attributes: {
           }}/**SCHEMA_VIEW_MODEL_CONFIG*/,
       modelConfig: /**SCHEMA_MODEL_CONFIG*/{}/**SCHEMA_MODEL_CONFIG*/,
       handlers: /**SCHEMA_HANDLERS*/[
           {
               request: 'crt.HandleViewModelInitRequest',
               handler: async (request, next) => {
                   const viewModel = request.$context;
                   viewModel["WorkplaceNavigationPanelVisibleAttribute"] = false;
                   return next?.handle(request);
               }
           },
           ]/**SCHEMA_HANDLERS*/,
       converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,
       validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/,
   };
});

 

Hope this will help you.

Show all comments