Reputation: 117
I'm displaying a view using a viewPanel. The view contains some columns which are enabled to be sorted in both directions, which is working fine.
Now I'd need to find out if the view has been resorted by the user by being clicked on the "Sort Toggle" in the viewColumnHeader.
Is there a property or a method which I can access programmatically to find this out?
Or is there an event in the viewPanel I could intercept or listen to?
Update:
I found that the class UIViewColumnHeader (which is extended by XspViewColumnHeader) has some static properties describing the icons (see here) - could I check for them? And if yes, how?
Upvotes: 1
Views: 453
Reputation: 117
Ok, with the help of those both sites, I solved resp. worked around my problem:
First, there was Naveen's solution how to Getting ViewPanel Headers programmatically
Second, Mark Leusink's article about the order of events in XPages.
This led me to following code:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:
var viewPnl:com.ibm.xsp.component.xp.XspViewPanel = getComponent("viewPanel1");
var list:java.util.List = viewPnl.getChildren();
var replaceRespCol = false;
for (var i = 0 ; i < list.size(); i++) {
var viewCol:com.ibm.xsp.component.xp.XspViewColumn = list.get(i);
var viewHdr:com.ibm.xsp.component.xp.XspViewColumnHeader = viewCol.getHeader();
if (@RightBack(viewHdr.getSortIcon(), "/") != "sort_none.gif") {
replaceRespCol = true;
}
}
if (getSearchKey() != "") {
getComponent("viewColumn1").setRendered(false);
getComponent("viewColumn1b").setRendered(true);
} else if (replaceRespCol == true) {
getComponent("viewColumn1").setRendered(false);
getComponent("viewColumn1b").setRendered(true);
} else {
getComponent("viewColumn1").setRendered(true);
getComponent("viewColumn1b").setRendered(false);
}}]]></xp:this.beforeRenderResponse>
which enables me now to dynamically show a categorized column (viewColumn1)
- if no filter/search key is entered and
- no re-sort via the headers is done.
Otherwise, a flat column (viewColumn1b) is shown. HTH
Upvotes: 0
Reputation: 15739
The sort column should be defined on the dominoView datasource in the sortColumn property, whose Java class is com.ibm.xsp.model.domino.DominoViewData. That can be accessed by calling getData() on the ViewPanel
So you should be able to use getComponent("myViewPanel").getData().getSortColumn() in SSJS. By default I suspect it will be blank.
Upvotes: 2