03-25-2014 07:30 AM
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
03-27-2014 12:26 PM
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
04-17-2014 04:18 AM
Hi,
when planing to hide a tab in a MainView where should I put this part of code?
Br Axel
05-19-2014 03:22 PM - edited 05-19-2014 03:23 PM
This code goes in a compiled custom module you must build in Visual Studio. See this thread:
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); } } } }