View panel view name calculated at runtime

I am having great difficulty setting up a view panel control’s view name based on a scoped variable

I know that the control has a handle on the correct value because I have a computed field displaying the value - but whenever I try to set the view name to “Computed value” with the same value, the app does not load the view

Am I missing anything?

Mike

Subject: Yes. ViewPanel can’t do this, afaik…

  • I know the name is computed, but viewPanel is shockingly limited in so many ways it would be funny if this were sitcom. But it’s not a sitcom, and it’s not funny, and even though you may compute the View name for the control, it will not function correctly. This should be present in numerous posts all over this forum, and easily locatable by searching.

  • Look on the web for how to do a View using repeat controls, or data tables. I personally did a repeat control because I stumbled on Dec’s Dom Blog first, and used his code as a model. I’ve extended it considerably, and even gotten categorized Views to work, after many, many, many failed attempts.

Good luck, Mike, and welcome to XPages, where the difficult is simple and the simple is difficult…

Subject: Not my favourite sitcom!!!

Many thanks David for your reply

I agree - it is almost too funny for words. Almost!

My view panel is inside a repeat control getting data from several different databases (all the same view name in each but as a model professional, I thought it best to parameterise it for future developers should things change! How silly of me)

Your post has convinced me that maybe I need to ditch the view panel and start thinking about data tables or some other way to display the data and allow the user to click to open the notes document itself. Any suggestions on the best control to delve into?

Thanks again

Mike

Subject: Search the web…

  • There are numerous examples on how to render Views. I used Dec’s Dom Blog, because way back when it was one of the first to have any extensive tutorial information about XPages. Now that sort of stuff is in blogs all over the 'net. I don’t have links … I just search when I need something. Scouring the web is a skill any developer should have.

  • Dec uses repeats on a single data source, but no matter what you’re doing the viewPanel you have now should be linked to something. Just link that to a repeat, using Dec’s (or someone else’s) post as an example.

  • I used three repeats:

  1. Repeat over the columns and dump the headers.

  2. Repeat over the rows.

    1. Repeat over the columns for each row and dump the data
  • Pagers work as expected on (2. Repeat), and Dec has a right nice custom pager I snagged.

  • What you do inside (2. Repeat) is utterly and completely up to you. I have responses as indented links embedded on my primary rows, hot-tracking (Dec’s blog covers this as well), independent colorization of text & background by the current row’s data, column icons, and totals. The limit is what you can noodle out. All of this works by simply passing the name of a View to the control, and setting up the View properly, which is consistent with usage in both the legacy Notes Client and on the web so Views are still sharable.

  • I currently use a separate control for categorized Views because that has pre-render setup code that I don’t want to waste time running if it’s not categorized. I did categorization as suggested by Wissel (who had no examples last I looked), where the categories are combo boxes at the top of the View, and changing them dynamically updates what appears below, with all of the rendering capabilities mentioned above. Figuring out nested collapsable tables simply required more time than I had, and I didn’t find any suitable starting point on the 'net.

  • So this is possible. It’s just a serious PITA that took me many, many hours to work out. The basic bits, though, are practically copy and paste from Dec’s Xpages Tutorial, so an usable presentation is possible relatively quickly. Again I want to stress that his isn’t the only way, it’s just the way I used.

Good luck!..