Custom view for a query web part - is there a way not to display the bar with the View name.

LabKey Support Forum (Inactive)
Custom view for a query web part - is there a way not to display the bar with the View name. Leo Dashevskiy  2015-04-06 15:09
Status: Closed
 
Hello, folks!

We are rendering a QueryWebPart into a panel's body. We dynamically generate it based on the supplied queryName and schemaName. For one such combination, it is necessary to provide in the config a custom viewName.
We see that in such case there's a bar above the main grid showing the view name that can be closed via the X button at the right end.

Is there a config or a param to specify not to show this top bar by default?
Or at worst is there a way to click the X button programmatically?

Thanks.
-Leo
 
 
Jon (LabKey DevOps) responded:  2015-04-06 16:29
Hi Leo,

Yes, you can make that entire section disappear by adding the following to the code that creates your QueryWebPart.

buttonBarPosition: 'none'

That removes the entire button bar above it, including the viewName field that you're seeing.

Regards,

Jon
 
Leo Dashevskiy responded:  2015-04-07 08:27
Thanks, Jon.

We would like to keep the top button bar, though.
So seems like currently there is no simple way to achieve what I'm after.
 
Jon (LabKey DevOps) responded:  2015-04-07 10:47
Hi Leo,

Well, you can sort of get away with what you want, but it's going to look a little counter-intuitive.

That buttonBarPosition has four options:

- top
- bottom
- none
- both

Each one will dictate where that buttonBar appears. Although our docs say that "both" is used (the buttonBar appearing on the top and bottom of the screen), I believe this was changed to "top" since I haven't seen a QueryWebPart within a wiki that has them both appearing as of late.

Now, if you use the option for "bottom", the buttonBar appears at the bottom of the screen, but you don't see that view name appearing anywhere - no X to click. This is due to the view Name displaying in conjunction with the top buttonBar. No top buttonBar, no view name to see. But on an aesthetic-level, having the buttonBar at the bottom doesn't look quite as nice as the top, but it will at least give you what you want - a buttonBar but no mentioning of the view that comes up by default via your query.

Regards,

Jon
 
Leo Dashevskiy responded:  2015-04-07 10:53
Yeah, we'd like to keep the top button bar, of course, since it is aesthetically better, we think.

Thanks, anyways.
 
Leo Dashevskiy responded:  2016-03-02 11:56
No longer relative (decided to keep the closable View Name ribbon).
 
Will Holtz responded:  2016-03-02 15:58
I had this exact same problem and was eventually able to get the functionality you asked for with the following code:

function hideGridMessages(dataRegion, request) {
    var task = new Ext.util.DelayedTask(function(x) {x.hideMessage();}, this, [dataRegion]);
    task.delay(15); // display of messages is delayed by 10 in DataRegion.js
}

var qwp1 = new LABKEY.QueryWebPart({
     schemaName: schemaName,
     queryName: queryName,
     renderTo: 'MyDiv',
     success: hideGridMessages
});

One downside of this method, is that the View Name ribbon will briefly display before being hidden. But in many cases, you won't even notice unless you are trying to see it happen.

-Will
 
Leo Dashevskiy responded:  2016-03-02 16:08
Thanks, Will, will keep that in mind, it does work, wondering why other LK devs didn't point that out...
 
Leo Dashevskiy responded:  2016-03-02 16:15
And also you don't have to use the "delay" approach:

var onRender = function(){
    var dataregion = qwp1.getDataRegion();
    dataregion.hideMessage();
};

var qwp1 = new LABKEY.QueryWebPart({
    schemaName: schemaName,
    queryName: queryName
});

// note the absence of the "renderTo" config option

qwp1.on( 'render', onRender ); // I believe, "onRender" method must physically in the code precede this call
qwp1.render( 'MyDiv' );