Hi,
I have a xPage containing a view control.
The view is categorised and works fine.
Now i wanted to add “Expand All” and “Collapse All” buttons to it, but i couldn’t figure out how.
I created a “link-controle” and added as the “Javascript (server-side)” the formula “@Command( [ViewExpandAll])”.
I looked through the object models and searched help but also nothing.
I know that this is probably trivial, but i am new to xPages amd javascript. 
Thank you in advance.
Lars
PS: I also want a “Refresh”-button for the view. But i guess that i can figure it out by myslef once i know the Expands/Collapses
Subject: The view has a property for this
The @Command() won’t work in the XPages context. But the ViewData source has a property ‘expandLevel’ that you can either compute, based for example on a sessionScope variable. Have your links changing this value in the session scope and you’e doneYou can also set the value programmatically, but this won’t last between different pages.
Subject: Thanks, but still no luck
Hi,
I tried your idea but i seem not to get it right:
-
my view has only one category
-
if i set the view-property “dara\expandlevel” fixed to “1” then it is collapsed. If to “0” then its expanded
-
in my Expand button i have added the following code: sessionScope.viewMode = 0; (and in the collapse buttons it is 1)
The buttons are set to do a “Full Update”
I have tested with print that the sessionScope variable is set properly after each button is clicked.
In my view\data\expandLevel i have added this code:
print("View-Expandlevel is : " + parseInt(sessionScope.viewMode));
return parseInt(sessionScope.viewMode);
The problem now semms to be that the “Full Update” does not trigger the view to recalc the “ExpandLevel”. I can see the Print-output on the console only once when the page is loaded. Then even that the page updates is does not appear anymore.
I have tested that when the sessionScope-variable is set to “Expand” and the view is opend the first time, it really is expanded. And oterwise.
If the “Full Update” not enough ?
Do i have to reopen the whole page ? (How do i do this the best way in a server-side script ?)
Or am i missing something ?
Thanks
Bye
Lars
Subject: Solution.
Hi,
at last i have found a solution for the “Expand All” and “Collapse All” buttons.
The code in my Expand-Button is:
sessionScope.viewMode = VIEWMODE_EXPANDED;
context.reloadPage()
The collapse button:
sessionScope.viewMode = VIEWMODE_COLLAPSED;
context.reloadPage()
The constants are defined as follows in a server side script-lib:
VIEWMODE_COLLAPSED = 1;
VIEWMODE_EXPANDED = 0;
In my view-control the property data\data\ExpandLevel is set to:
return parseInt(sessionScope.viewMode);
It works. But i don’t know if this is the proper way how to do it.
If you have some better solution please post.
(I am still a newbie in xPages 
Thanks a lot for your help.
Bye
Lars
Subject: another option
Hi,
Here’s another solution for expand/collapse all buttons. Create a custom control with two buttons, and add the following code to them respectively
for “collapse all”:
var viewPanel = getComponent(compositeData.viewPanelName);
var model:com.ibm.xsp.model.domino.DominoViewDataModel = viewPanel.getDataModel();
var container:com.ibm.xsp.model.domino.DominoViewDataContainer = model.getDominoViewDataContainer();
container.collapseAll();
for “expand all”:
var viewPanel = getComponent(compositeData.viewPanelName);
var model:com.ibm.xsp.model.domino.DominoViewDataModel = viewPanel.getDataModel();
var container:com.ibm.xsp.model.domino.DominoViewDataContainer = model.getDominoViewDataContainer();
container.expandAll();
Define a property for the control named “viewPanelName” and make it required. After that you can add your custom control to any view and only have to specify the name of your view panel as a property, like this:
<xc:viewControls viewPanelName=“viewPanel1”></xc:viewControls>
where viewControls is the name of the custom control.
Tibor