In this article I will demonstrate a technique for dynamically expanding and contracting viewPanel rows. This provides a nice clean interface for the user and allows content to be made visible as necessary. This article also highlights many of the core jQuery capabilities.
When moving from a notes client application to the web often times view columns can be large and unwieldy
A boring notes view
Unwieldy data view on an XPage
What we are going to do is not only neaten up the display but provide some simple user interactivity to allow access to data as needed. Here is a quick video of the capability in action.
You can see a working example of the capability on the xomino site. In Firefox and Chrome the fade effect look just fine but due to issues with alpha filters fade does not work consistently in IE.
How does it work?
As you can see from the pictures above, once we put our view into an xPage and display it on the web, the entire contents of the data field are displayed on the page. This can make for an irritating session with customer who don’t want to have to scroll page after page to find their information but want the same view to be available through the notes client.
Once solution would be to determine the medium through which your data is being viewed and truncate it accordingly. But I went another route and made a compromise where the data is available if the users wants it (adding functionality to the page without them having to click and open the document) but does not take up a large amount of space.
I added jQuery and jQueryUI (CSS not code) to my database through the WebContent folder and to my XPage like this
Select all the 4th column Table cells in the viewPanel and cycle through each of them
//select all elements (one in this case) where the id ends with (id$=) viewPanel1
//within that select all rows (tr)
//within that select all the table cells (td)
//within that select only the cells which are the 4th child element (:nth-child(4))
//cycle through each of them (.each(function(i)) where i is the nth item in the cycle
$("#[id$='viewPanel1'] tr td:nth-child(4)").each(function (i)
Because we have fixed the column width we are able to accurately ascertain the height of the cell contents on the page
As we then cycle through the viewPanel TD cells we determine if the cell contents are larger than 100pixels. If they are then we surround the contents with a wrapper with a fixed height.
//$(this) means each jQuery object (representing the TD as we cycle through the column
//.append is as it sounds - append to the end this SPAN (with the arrow in it)
//.children(:first) selects the first SPAN within the TD we are working on and
//.wrap means surround the SPAN with the DIV
$(this).append('<span class="ui-icon ui-icon-arrowthick-1-s"></span>').children(":first").wrap('<div class="wrapper" />')
ok trying to visualize what is going on we start with something which looks like this
We .append() another span
We then .wrap() the :first Child of the TD with a Div
And there you have it. We have looked at a broad range of jQuery capabilities and brought them all together to create a great looking interface for the end user. All these capabilities are part of the jQuery core and I only used jQueryUI to get the cute up and down arrows. If you wanted to use an icon there is nothing stopping you removing the jQueryUI dependency.
We have looked at jQuery Selectors
attribute selector $(“#id$=
class selector $(‘.wrapper
We have looked at DOM traversing and manipulation techniques
We have looked at attaching events to DOM elements
We have looked at object properties
We have looked at multiple visual manipulation capabilities
x$ – now a part of XPages Extension Library
Tue, Nov 18th 2014 9:16p Mark Roden I am very flattered to find out that not only is my x$ OpenNTF xSnippet being used more widely than I realized (over 600 downloads). It now being used in the latest release of the OpenNTF Extension library.
If you look here – http://bootstrap4xpages.com/xsp/.ibmxspres/.extlib/responsive/xpages/js/xsp-mixin.js and search for it you will find
//jQuery selector that works with XPages IDs
//See - http://openntf.org/XSnippets.nsf/snippet.xsp?id=x-jquery-selector-for-xpages
function x$(id [read] Keywords: xpages community
One way to make a responsive XPages viewPanel
Tue, Nov 11th 2014 7:41p Mark Roden In this article I will demonstrate a method for hiding columns using CSS and making an XPages view Panel pseudo-responsive.
What is Responsive Design?
Responsive design is an approach to web page creation that makes use of flexible layouts, flexible images and cascading style sheet media queries. The goal of responsive design is to build web pages that detect the visitor’s screen size and orientation and change the layout accordingly.
http://whatis.techtarget.com/definition/responsive-des [read] Keywords: xpages css
Finding your localStorage values – Chrome Developer Tools
Thu, Nov 6th 2014 8:05p Mark Roden Just a quick tip – if you use localStorage and you need to find out what values you have in localStorage you can see them through developer tools easily.
F12 to pull up developer tools
Local Storage is right there
A similar feature will be release in the next Firefox (34) developer tools – https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector [read] Keywords: firefox
Because developers make mistakes – Webstorm Local History
Wed, Nov 5th 2014 10:24p Mark Roden Similar to Eclipse, Webstorm has a local history capability, allowing the developer who realizes they made an idiot mistake an hour ago, to go back to it and save their day.
We’ve all been there and while committing to source control is a must for modern development, there are those times in between commits and then those when you are just too lazy to go through the repo looking for it.
Local History is always enabled in Webstorm – for the official help check here.
U [read] Keywords: development
Conditional style loading in IE10+
Sun, Nov 2nd 2014 8:12p Mark Roden I learned this recently when trying to load a conditional stylesheet into an XPage. IE9 worked but IE11 failed on me and I couldn’t see why. It was only a small change so I ended up putting it in the main stylesheet as a media query.
Apparently IE10 and above does not understand conditional HTML code like this
So to load a style conditionally in IE11 you can do it like this
@media screen and (-ms-high-contrast: a [read] Keywords: css
Binding jQuery code to an XPages partialRefresh using DOM Mutation events
Wed, Oct 29th 2014 7:38p Mark Roden Introduction
In this article I will demonstrate how to bind to the event which triggers on the completion of an XPages partialRefresh. Using that binding we will then be able to action to contents of the newly added partialRefresh DOM elements.
In multiple articles I have discussed the use of the onComplete event of a programmatically triggered partialRefresh to be able to re-apply a jQuery plugin’s bindings to an area of an XPage. This works very nicely and integrates with the [read] Keywords: domino