conditional names on views?

LabKey Support Forum (Inactive)
conditional names on views? Ben Bimber  2010-10-25 11:58
Status: Closed
 
on each labkey page, in the upper left corner, immediately below the menu bar there's a title. This is determined by the name of your view or wiki page. You can edit this title in the .view.xml file. However, can I conditionalize this using JS code? My specific scenarios are things like:

1. We might want the title to be something like 'Animal Id: '+subject, where subject is a variable taken from the URL or other code

2. We might have a single HTML/js page that load forms. There might be a url param that sets formType. We might want the page titled 'Physical Exam' or 'Weight', depending on this param.

thanks for the help.
 
 
marki responded:  2010-10-25 13:28
If I understand you correctly you are looking for the first parameter of LABKEY.NavTrail.setNavTrail

https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.NavTrail.html#.setTrail
 
Ben Bimber responded:  2010-10-25 13:37
yes, that's exactly what i'm looking for.
 
Ben Bimber responded:  2010-10-28 09:00
hi mark,

i attached a screenshot. there's two places with title on a view: the title that appears in the top-left (which is set using LABKEY.NavTrail.setNavTrail) and a title that is given to the webpart on the page. This particular view based is an HTML file in a simple module. All the page does it load an ext panel into a div. If I understand this correctly, labkey automatically displays the webpart-like border around file-based views. It seems to give this border a title based on the name of that view. Is there a js API to customize that?
 
marki responded:  2010-10-28 11:13
You can customize the frame with yet another XML file. Given a view file

begin.html

you can create

begin.view.xml

with content like this:

<view xmlns="http://labkey.org/data/xml/view"
     frame="none">
   <permissions>
       <permission name="read"/>
   </permissions>
</view>

The frame attribute is the one you need. By default the value is "portal" which was probably a mistake. Not sure if it is too late to change tho. The possible options are in the xsd

https://www.labkey.org/download/schema-docs/xml-schemas/

The help for this is pretty far down the page here:

https://www.labkey.org/wiki/home/Documentation/page.view?name=moduleqvr
 
Ben Bimber responded:  2010-10-28 11:17
should have been a little clearer: the xml lets you give all instances of that view the same name. we've done that in some other cases.

can i use JS to set a custom name based on some other logic? for example, changing the title based on the type of form being loaded (assuming one HTML file loads every type of form) or appending animal ID to the title?
 
jeckels responded:  2010-10-29 11:07
Hi Ben,

We don't have an API to set this, but it's possible to use XPath in JavaScript to get the DOM element for the header and change its text content. As you'd expect, this could break in a future release if we change the way we generate the HTML for the header.

Thanks,
Josh