Subscribe via Feed

Adding XPages Controls to a View Panel's Column

Paul Hannan, Nov 9, 2009 11:39:23 AM


Here's a technique that you might find handy to help you customise your XPages view. 


View Panels are great though they can be inflexible. I prefer using Data Tables or Repeats when I want to do some fancy stuff, stuff that's not always easy to do on a View Panel. But if you don't want to go down the Data Table or Repeat route just yet this tip will help you get more out of a View Panel.

  • Take any View Panel and insert or append a column; 
  • Next switch to the Source pane and for this new column add in a blank value for this column - a column need a value in order for it to work at runtime; 
  • Next, add in a control between the viewColumn tags;
  • Configure the control to what is desired, and you're done.

 This snippet of a view panel contains a customised column, and in the following example I've added a link control. I'm using the link control here as I want to use the 'target' property which isn't available to me when the column is set to display as a link.  



xp:key="headerPager" id="pager1">















value="a link with a Target property">


target="_blank">



 

 

 

So what do you do if you want to work with the data in the row?

First thing you do here is add a var to the viewPanel. This will become your data collection reference and you'd used this to configure control in very much the same way as you would on a Data Table or a Repeat.

 

var="vp1">
...



value="Subject">


}"
id="link3">
refreshMode="complete">

documentId="#{javascript:vp1.getNoteID()}">






 The above example is very useful for when you want to open a document in an alternative XPage other than the XPage that is set to open by the View Panel.

 

Going another step further, how about adding a rich text control to the view panel column and displaying a rich text field from that document?

Well here's one way. As with the above, add a Panel to view column and set the document data source of this panel to the form that contains the rich text item you need. Then use the row id as the document id of the document the data source is to use. Next add a Rich Text control to the panel and bind it to the rich text field from the form.

The view panel column source might look like this...

 

action="openDocument" documentId="#{javascript:vp01.getNoteID()}">
readonly="true">

 

And at runtime, it might look like this...

 

 

Hope this helps.

p.



10 responses to Adding XPages Controls to a View Panel's Column

Kumar, February 15, 2011 7:50 AM

Hello Paul,

I tried above I am getting See attached file for attachment in the column and no attachment any idea i used var as d1 in the view panel and inserted that as d1.getNoteID() in panel data properties.Thanks.


Wayne Allen, January 10, 2011 3:21 AM

Good article - very informative.


Patrick Picard, October 13, 2010 5:16 PM

This trick saved me a few hours of grief today :) Thanks


REynald, November 23, 2009 2:46 AM

Hi,
is there any way to sot the column in repeat control. Thanks


dave, November 18, 2009 8:43 AM

I tried with such code pattern to adjust view panels column but didn't get perfect result.I think I get the perfect code and technique to overcome errors of my code.
vitamine


Mike VandeVelde, November 12, 2009 5:43 PM

Ah! Don't use the onclick event, just compute the url for the link. getOpenPageURL is handy!

Success!

Thank you sir :-)


Mike VandeVelde, November 12, 2009 5:35 PM

I don't see any way to combine the two? ie use the data in the row to open a specified XPage, with target="_top"?


Dirk Meyer, November 11, 2009 2:51 PM

Hi Paul,

thanks for the update!
I never had the idea to just add a var="xy"...


Paul Hannan, November 10, 2009 2:24 PM

Hi Dirk,
That's a good point and I'll updated the doc to show how this can be done.
The first thing you do is add a var to the viewPanel, then you use this var as the data collection id. Then you'd configure the controls in the same way as you would with a Data Table or a Repeat.
p.


Dirk Meyer, November 10, 2009 11:10 AM

Hello Paul,
nice trick!
Is there also a way to get a handle of the current viewEntry or document inside the viewPanel, like in a repeat control? For example to compute the url of the xp:link?