Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
New Member
Posts: 5
Registered: ‎09-09-2013

Hide Tabs at Runtime (SLX 8.1)

Hi,

 

how can I hide a Tab at runtime? The code below is not working...

 

Sage.Entity.Interfaces.IEvent CurrentEvent = this.BindingSource.Current as Sage.Entity.Interfaces.IEvent;

Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace tabs = this.ParentWorkItem.Workspaces["TabControl"] as Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace;

tabs.Hide("FormID", true); // true = hide, false = show

 

Other ideas?

 

 

Thanks fpr help!

Charly

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Hide Tabs at Runtime (SLX 8.1)

You can try the following, assuming you have a custom:

 

using Sage.Platform.Application.UI.Web;
using Sage.Platform.WebPortal.Workspaces;
using Sage.Platform.WebPortal.Workspaces.Tab;

[ServiceDependency]
public IPageWorkItemLocator PageWorkItemLocator { get; set; } 

var workItem = PageWorkItemLocator.GetPageWorkItem();
if (workItem != null)
{
	var tabWorkspace = workItem.Workspaces["TabControl"] as TabWorkspace;
	if (tabWorkspace != null)
	{
		tabWorkspace.Hide("YourSmartPartId", true);
	}
}

You can also add logging to see if there is some other problem, by adding the followign to log4net.config:

 

<logger name="Sage.Platform.WebPortal.Workspaces.Tab.TabWorkspace">
	<level value="DEBUG" />
	<appender-ref ref="EventLogAppender" />
</logger>

Thanks

 

Mike

 

 

New Member
Posts: 1
Registered: ‎04-17-2014

Re: Hide Tabs at Runtime (SLX 8.1)

Hi,

when planing to hide a tab in a MainView where should I put this part of code?

 

Br Axel

Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Hide Tabs at Runtime (SLX 8.1)

[ Edited ]

This code goes in a compiled custom module you must build in Visual Studio. See this thread:

 

http://community.saleslogix.com/t5/Developer-Web-Discussions/Problem-hiding-tabs-at-runtime-Web-7-5-...

 

In Visual Studio, for 8.1 you have to target .NET 4.0 and x86. I had to change a few things from the code in the above thread to get everything to work right.

 

Once complete, you must add the resulting .dll to your Portal/SLXClient/Support Files/bin folder, then add the module to the page e.g. Portal/SLXClient/Pages/AccountDetails the same as any SmartPart.

 

Here's what I ended up with that worked for what I wanted to do:

 

Add References (copy from bin folder in your saleslogix website e.g. C:\inetpub\saleslogix\slxclient\bin):

Microsoft.Unity

Sage.Entity.Interfaces

Sage.Platform

Sage.Platform.Application

Sage.Platform.Application.UI.Web

Sage.Platform.WebPortal

Sage.SalesLogix.Client.GroupBuilder

Sage.SalesLogix.Client.GroupBuilder.Modules

Sage.SalesLogix.Security

Sage.SalesLogix.Web

System

System.Web

 

using System;
using System.Collections.Generic;
using System.Text;

using Sage.Platform.WebPortal;
using Sage.Platform.WebPortal.Services;
using Sage.Platform.WebPortal.SmartParts;
using Sage.Platform.WebPortal.Workspaces;
using Sage.Platform.WebPortal.Workspaces.Tab;
using System.Web;
using Sage.SalesLogix.Security;
using Sage.SalesLogix.Web;
using Sage.Platform.Security;
using Sage.Entity.Interfaces;
using Sage.Platform;
using Sage.Platform.Application;
using Sage.Platform.Application.UI;
using Sage.Platform.Application.UI.Web;


namespace Custom.SalesLogix.Client.Modules {
public class AccountModule : IModule {
[ServiceDependency] public IPageWorkItemLocator PageWorkItemLocator { get; set; } [ServiceDependency(Type = typeof(IEntityContextService), Required = true)] public IEntityContextService EntityService { get; set; } public void Load() { if (EntityService == null) return; IAccount account = EntityFactory.GetById<IAccount>(EntityService.EntityID.ToString()); if (account == null || PageWorkItemLocator == null) return; PageWorkItem workItem = PageWorkItemLocator.GetPageWorkItem(); if (workItem == null) return; TabWorkspace tabWorkspace = workItem.Workspaces["TabControl"] as TabWorkspace; if (tabWorkspace == null) return; if (account.Type == "Customer") { tabWorkspace.Hide("AccountOpportunities", false); } else { tabWorkspace.Hide("AccountOpportunities", true); } } } }

 

Andy Freeman
TrellisPoint, LLC