Hiding the first tab of accordion panel in JSF Primefaces

左心房为你撑大大i 提交于 2019-11-30 12:22:10
Sebi

One approach is to define a widgetVar:

<p:accordionPanel widgetVar="accordion">
    ...
</p:accordionPanel>

And then:

<body onload="PF('accordion').unselect(0)">

or for older PF versions:

<body onload="accordion.unselect(0)">

You can just do

<p:accordionPanel activeIndex="-1">

It works if you set activeIndex to blank (Primefaces 3.4.1).

<p:accordionPanel activeIndex="">

None of the posted answered worked for me in PrimeFaces 3.5.x. using multiple mode, but this:

<p:accordionPanel multiple="true" activeIndex="null" ... >

You can do it with the PF function, as the code below:

PF('accordionWidgetVarName').unselect(0);

Answering for PrimeFaces 6.0 users:

You can set the widgetVar property and then call PF('widgetVarValue').unselect(0); as Fred Policarpo mentioned; however, I was not able to get this to work upon accordion load, and I tried various things like using a div's onload event, using a remoteCommand with autoRun enabled, and even using custom jQuery. None of these worked for the load event, only when I ran that PF unselect call in the console.

In PrimeFaces 6.0, you can use the activeIndex attribute and set it to multiple values, e.g. "1,3,5", to close all of the tabs but open the 2nd, 4th, and 6th tabs (base 0 indexing).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!