HOWTO: Hide empty subpanels on the DetailView

sugarcrmdevelopers —  April 20, 2011 — 9 Comments

Each DetailView for a record in Sugar often has several subpanels displayed with it, which lists of related records to the current record. For example, on an Accounts record there is a subpanel displaying all of the related Contacts to that Account record. This provides a great view into the all the related records from a single place.

But often times there are several subpanels that have no data on them, and displaying them can take up valuable screen real estate. This forums poster asked if there was a way to eliminate this, and after a bit of hacking I figured out a solution which should work on any Sugar 6.0-6.2 instance. I will warn you this is not in anyways upgrade-safe, but the code changes are pretty minor so hopefully that won’t be too big of a deterent.

The first change is in the include/ListView/ListView.php file, where we need to pass the panel name to the XTemplate form. The changes are below and indicated in the commented section.

Next, we need to update the file include/SubPanel/SubPanelDynamic.html, which handles the general layout of the subpanel itself. Here, we will add some javascript code which will dynamically hide the panel if there are no records present.

You can now go to any DetailView and if the subpanel has no data, it will be collapsed.


9 responses to HOWTO: Hide empty subpanels on the DetailView


    Thanks John,
    Why not put this code in “source” of all Sugar Product ?

    Best regards.


    that does’t work for subpanel for activites


    I’d like to echo carrabaz’s comment and add that this also doesn’t work on the History subpanel, either


    While adding this feature is definitely useful, aside from the History and Activities subpanels not collapsing, I also noticed that now, subpanels that DO have data are also collapsed, if the user previously collapsed said panel. What code would I need to add that would expand subpanels that do have data? Possibly something in an else statement in the

    ListView.php file?

    We want to be able to force this behavior so users don’t assume subpanels are collapsed because there is no data in them, when in fact there may be.


    It’s not working in 6.4.


    I have found some interesting information for this hack:

    The reason that activities and history does not hide is that those panel names are being sent as “meetings” for some reason.

Trackbacks and Pingbacks:

  1. Forcing subpanels that DO have data to be expanded in DetailView - SugarCRM Forums - January 16, 2012

    […] subpanels that DO have data to be expanded in DetailView There is a developer blog article that explains how to modify some core files so that subpanels are collapsed in the detailview when […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s