357 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
The consummate Champion
Thu, Jul 24th 2014 183
Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 185
Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 241
Hi Chicago – what changed?
Wed, Jul 2nd 2014 266
Angular.js in XPages #6 – A People Manager CRUD application
Sun, Jun 1st 2014 421
Angular.js in XPages #5 – Routing
Sun, May 25th 2014 314
WebSockets comes to XPages!! Awesome – Awesome – Awesome
Tue, May 20th 2014 474
Top 10
Arguably the most dangerous thing you could ever do in XPages – let other people use your eval() in their SSJS
Tue, Jun 18th 2013 1047
Why learning JavaScript is more critical to XPage developers than Java
Wed, Mar 26th 2014 933
An open letter to Mr. NotesIn9
Wed, Apr 2nd 2014 615
EXTJS in XPages #14 – Grid editing and saving data via REST CRUD
Thu, Aug 1st 2013 579
Adding custom HTTP headers to Domino R9 using IBM HTTP Server (IHS)
Sun, Apr 20th 2014 556
EXTJS in XPages #13: Totaling your columns with a groupingSummary
Sun, Jun 30th 2013 537
Angular.js in XPages #1 – Using the right IDE for development
Sun, Apr 27th 2014 507
And the gloves are off……
Mon, Mar 31st 2014 493
Why using XPages Partial Refresh is sometimes easy for developers and bad for users
Tue, Mar 4th 2014 482
WebSockets comes to XPages!! Awesome – Awesome – Awesome
Tue, May 20th 2014 474


Dynamically Expanding XPage viewPanel Rows on mouseover
MarkyRoden    

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.

Problem

When moving from a notes client application to the web often times view columns can be large and unwieldy

A boring notes view

A boring notes view

Unwieldy data view on an XPage

Unwieldy data view on an XPage

Solution

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.

Demonstration

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

	<xp:this.resources>
		<xp:script src="js/jquery-1.7.2.min.js" clientSide="true"></xp:script>
		<xp:styleSheet
			href="css/custom-theme/jquery-ui-1.8.19.custom.css">
		</xp:styleSheet>
	</xp:this.resources>

I started out by creating a data source of my view and dragging the fields to the XPage, creating a viewPanel on the form. I then “fixed” the width of someData column:

		<xp:viewColumn columnName="somedata" id="viewColumn4">
			<xp:this.facets>
				<xp:viewColumnHeader value="Somedata" xp:key="header" style="width:300px"
					id="viewColumnHeader4">
				</xp:viewColumnHeader>
			</xp:this.facets>
		</xp:viewColumn>

I then created a scriptblock on the XPage after the viewPanel (controls > other > core controls >scriptblock). Within all Properties > data > value I added the following code….

			 $("#[id$='viewPanel1'] tr td:nth-child(4)").each(function (i) {
			 	if ($(this).innerHeight()>=100){
				 	$(this).append('<span class="ui-icon ui-icon-arrowthick-1-s"></span>').children(":first").wrap('<div class="wrapper" />')
			 	}
		    });

and that on its own made quite a difference….

modified viewPanel

modified viewPanel

This is what the jQuery code just did

  • 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

<td>
  <span #1>
  </span>
</td>

We .append() another span

<td>
  <span #1>
  </span>
  <span #2>
  </span>
</td>

We then .wrap() the :first Child of the TD with a Div

<td>
  <div>
    <span #1>
    </span>
  </div>
  <span #2>
  </span>
</td>

And this is what we have made (looking at it through FireFox FireBug

The new Table Cell viewed in Firebug

The new Table Cell viewed in Firebug

You have to admire the ability to “chain” jQuery objects and methods together :)

Styling the wrapper

We add the following stylesheet to the XPage to ensure that the DIV .wrapper class keeps the display in check

	<style>
		.wrapper {
			height: 50px;
			overflow: hidden;
			padding-bottom: 5px;
		}
	</style>

Animating the Table Rows

So once we now have our reformatted table rows they look better but anything over 50px cannot be “read” as it is hidden.

What we are going to do is add an mouseenter and mouseleave event to the DIV class=wrapper we just added inside our table cell.

Here’s the breakdown in English and the code beneath it

on mouse enter

  • Select all table rows which are NOT the one we are currently over
    • Fade the whole row to 20%
  • Get the SPAN next in the DOM below the wrapper DIV (the one with the down arrow in it)
    • Toggle OFF the down arrow class (ui-icon-arrowthick-1-s)
    • Toggle ON the up arrow class (ui-icon-arrowthick-1-n)
  • Animate the height of the TD to match the height of the .wrapper

on mouse leave

  • Select all table rows which are NOT the one we are currently over
    • Fade the whole row back to 100%
  • Get the SPAN next in the DOM below the wrapper DIV (the one with the up arrow in it)
    • Toggle ON  arrow class (ui-icon-arrowthick-1-s)
    • Toggle OFF the up arrow class (ui-icon-arrowthick-1-n)
  • Animate the height of the TD to match the initial height of the .wrapper

			initHeight = $('.wrapper').height();

		    $('.wrapper').bind('mouseenter', function() {
		        $("#[id$='viewPanel1'] TR:gt(0)").not($(this).closest('tr')).stop(true, true).fadeTo('normal', 0.2);
		        $(this).closest('Div').next('span').toggleClass('ui-icon-arrowthick-1-n').toggleClass('ui-icon-arrowthick-1-s')
		        $(this).stop(true, true).animate({
		            height: this.scrollHeight
		        });
		    });
		    $('.wrapper').bind('mouseleave', function() {
		        $("#[id$='viewPanel1'] TR").not($(this).closest('tr')).stop(true, true).fadeTo('normal', 1);
		        $(this).closest('Div').next('span').toggleClass('ui-icon-arrowthick-1-n').toggleClass('ui-icon-arrowthick-1-s')
		        $(this).stop(true, true).animate({
		            height: initHeight
		        });
		    });

In summary

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
  • :nth-child
  • :first

We have looked at DOM traversing and manipulation techniques

  • .children()
  • .next()
  • .closest()
  • .not()
  • .append()
  • .wrap()
We have looked at attaching events to DOM elements
  • .bind()
We have looked at object properties
  • .innerHeight()
  • .height()
We have looked at multiple visual manipulation capabilities
  • .fadeTo()
  • .animate()
  • .toggleClass()
  • .stop()

Demonstration

You can see a working example of the capability on the xomino site.




---------------------
http://xomino.com/2012/05/07/dynamically-expanding-xpage-viewpanel-rows-on-mouseover/
May 07, 2012
74 hits



Recent Blog Posts
183


The consummate Champion
Thu, Jul 24th 2014 8:42p   Mark Roden
As Russ Maher said today in Hey Who got the Handsome Champion it is an honor and a privilege to not only be recognized by IBM as a Champion for ICS 2014, but you also get some very cool stuff. Thanks to Amanda Bauman and Oliver Heinz for organizing “the champions” and all the gear. I just wonder what I am going to do with all of it :) Seriously though, I am very humbled to be an IBM Champion ! Thank you to everyone who nominated me and made this possible :) [read] Keywords: ibm
185


Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 9:18p   Mark Roden
Web Components – the future You should first ground yourself on Web Components and read this article on Web Components and concepts, ShadowDOM, imports, templates, custom elements by Todd Motto. Then listen to this Podcast (thanks to Steve for pointing it out) - Web Components with Peter Gasston Once you have read/listened you will have some idea and concept about Web Components and how they are the future….. But what I wanted to show briefly was how to enable the ShadowDOM in C [read] Keywords: agent javascript podcast
241


Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 10:55a   Mark Roden
I am very fortunate and excited to announce that I have been accepted to speak at MWLUG 2014. MWLUG will always have a fond place in my heart because I had my first speaking session there back in 2012 and had such a fantastic time it pushed me to do more. I will speak speaking about Angular.js and the opportunity it avails us as Web Developers. We all know IBM Domino is arguably to world’s most secure and mature NoSQL database. So we will take a look at how we can use it like a NoSQL [read] Keywords: domino ibm xpages application applications database development server
266


Hi Chicago – what changed?
Wed, Jul 2nd 2014 7:16a   Mark Roden
Well it has been on the cards now for 6 months but we finally did it. My family and I moved from Virginia to Chicago and I have started working out of the PSC office in Schaumburg, IL. I was asked nearly 18 months ago if I would consider moving, but for mostly family reasons it took a year or so to organize and agree this was the right thing to do for my career and just as importantly for the family. Working at home has been wonderful for the past two years. But it was also a little limiting [read] Keywords: office
421


Angular.js in XPages #6 – A People Manager CRUD application
Sun, Jun 1st 2014 6:58p   Mark Roden
In this article I will bring together everything discussed in the first 5 articles and demonstrate how to create you first basic CRUD application using Angular.js and XPages. Previous articles Angular.js in XPages #5 – Routing Angular.js in XPages #4 – Using Domino Data Angular.js in XPages #3 – The first app Angular.js in XPages #2 – Setting up a Webstorm / Domino development environment Angular.js in XPages #1 – Using the right IDE for development Introduction In the last article w [read] Keywords: domino ibm ods R8 xpages application database development firefox iphone javascript properties server xml
314


Angular.js in XPages #5 – Routing
Sun, May 25th 2014 6:52p   Mark Roden
In this article I will show how angular using routing to create a bookmarkable URL string and how that fits together with additional controllers. This will start us on the path to creating our basic CRUD application. This article is based on the Routing and Multiple views tutorial  Routers Way back when the world was young (in internet terms a couple of years ago), when single page apps were all the rage, it was noticed that there was a significant drawback to only having one URL index.html; [read] Keywords: ibm xpages ajax application database xml




474


WebSockets comes to XPages!! Awesome – Awesome – Awesome
Tue, May 20th 2014 6:49p   Mark Roden
In this article I will introduce and discuss the OpenNTF WebSockets OSGI plugin by Mark Ambler. The websocket plugin posted to Mark Ambler is based on the http://java-websocket.org/ project. I realize I am not the first person to play with a websocket server on top of a domino database. I know of at least 4 other people who have at least done their own POC for this. But this is the first time I have got my hands on it :) I’m a little excited…… Playing websockets in XPages wit [read] Keywords: agent domino ibm notes rich text sametime xpages application community database integration java javascript network openntf server twitter xml
392


Angular.js in XPages #4 – Using Domino Data
Sun, May 18th 2014 6:36p   Mark Roden
In this article I will demonstrate how to use Angular.js to access Domino Data and display it in place of the hard coded data we used in the previous article. Introduction This article is based off the Angular developer tutorial on XHR and dependency injection . It is essential you go and read that article before continuing. It explains how dependency injection works, why it is used and about Angular services. Modifying the controller In our previous article we used a hard coded json string [read] Keywords: agent domino ibm ldd lotus lotusscript ods xpages ajax application database development java security server
404


Angular.js in XPages #3 – The first app
Sun, May 11th 2014 6:40p   Mark Roden
In this article I will recreate one of the simple Angularjs.org developer tutorials and relate it to how we would build an equivalent XPages application. Create the database As described in the previous article, set up a Domino database with an ODS. Then link your Webstorm to the new ODS structure. Download the Angular code from https://angularjs.org/ it will be an 8M download. Opening the zip file you will see a lot of “angular files”. These are “Dependency files” [read] Keywords: domino ods xpages application applications database development dojo google java server xml
334


Mastering XPages v2 – Review
Sat, May 10th 2014 8:55a   Mark Roden
In this article I will put forth my case as to why you need to buy Mastering XPages v2 – even if you already own v1 Introduction Maybe this book should be entitled – “So you think your an XPages expert? You are not a Master !” Clearly I am not a Master – and couldn’t possibly hope to be one and that is why *I* need this book….. The writing style Perhaps not the most obvious place to start but to me a significant one. There are many styles of writing for [read] Keywords: xpages application applications blogger community css development dojo java javascript mobile properties server




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition