354 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Angular.js in XPages series
Wed, Apr 23rd 2014 38
Adding custom HTTP headers to Domino R9 using IBM HTTP Server (IHS)
Sun, Apr 20th 2014 257
An open letter to Mr. NotesIn9
Wed, Apr 2nd 2014 424
And the gloves are off……
Mon, Mar 31st 2014 323
When the community comes together we get the right answer
Sun, Mar 30th 2014 296
Why learning JavaScript is more critical to XPage developers than Java
Wed, Mar 26th 2014 715
PATCHing a Document using Domino Data Service
Mon, Mar 24th 2014 199
Top 10
Why learning JavaScript is more critical to XPage developers than Java
Wed, Mar 26th 2014 715
Arguably the most dangerous thing you could ever do in XPages – let other people use your eval() in their SSJS
Tue, Jun 18th 2013 424
An open letter to Mr. NotesIn9
Wed, Apr 2nd 2014 424
Why using XPages Partial Refresh is sometimes easy for developers and bad for users
Tue, Mar 4th 2014 326
And the gloves are off……
Mon, Mar 31st 2014 323
Going porn-mode on your browser
Fri, Jan 24th 2014 320
Prototypal inheritance of SSJS across the whole server in XPages
Sun, Mar 2nd 2014 316
EXTJS in XPages #14 – Grid editing and saving data via REST CRUD
Thu, Aug 1st 2013 302
When the community comes together we get the right answer
Sun, Mar 30th 2014 296
Lowering your ODS – an oldie but goodie
Fri, Feb 7th 2014 283


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
47 hits



Recent Blog Posts
38


Angular.js in XPages series
Wed, Apr 23rd 2014 7:37p   Mark Roden
Introduction Angular.js is an Open Source (MIT) JavaScript framework created and maintained by Google. It is designed to help web developers create quick and functional applications, while reducing the overhead of data binding and state management. If you want to find out more about Angular then look at some of the myriad of great resources around the web. Angular Developer Tutorial New To Angular? Start Learning Here https://www.ng-book.com/ Angular.js the awesome parts (Video) Front end / [read] Keywords: domino xpages application applications community development google java javascript
257


Adding custom HTTP headers to Domino R9 using IBM HTTP Server (IHS)
Sun, Apr 20th 2014 6:41p   Mark Roden
IBM HTTP Server (IHS) was added to R9 so that we could have TLS support for HTTPS encryption. For more on how to do that see Russ Maher’s post(s) on the subject. Under the covers IHS is really a modified version of Apache Web server and comes with some of the Apache options. It gives us the ability to add custom headers to all pages served up by the server. You can turn IHS on by adding the following to your notes.ini – this does require a full reboot HTTPIHSEnabled=1 When the [read] Keywords: domino ibm notes xpages server
424


An open letter to Mr. NotesIn9
Wed, Apr 2nd 2014 6:33a   Mark Roden
Dear Mr Leedy, I regret to inform you that your blatant use of child labor has offended my child labor union. They do not feel like you have represented me in the correct light. I trust that you will find this short response in the same light as your original offense. yours faithfully, Your very good friend Marky Roden CC: everyone who has seen this video http://notesin9.com/index.php/2014/03/31/notesin9-141-java-vs-javascript-throwdown/ [read] Keywords: java javascript
323


And the gloves are off……
Mon, Mar 31st 2014 5:57p   Mark Roden
Picture this: I have been away for 5 days and during that time “someone” has been posting cryptic comments on twitter about how the next notesin9 is going to be different….and scaring me. So I am waiting at the airport this afternoon, about to board my plane home and I get this link from this “friend” who tells me to watch the new video it and enjoy. I download it and watch it on the plane. People start to look at me funny as I start to snort and giggle at my phone. [read] Keywords: ibm xpages application integration javascript twitter
296


When the community comes together we get the right answer
Sun, Mar 30th 2014 12:41p   Mark Roden
Last week I posted why JavaScript is more critical a skill to learn than Java. There was an outpouring of comments, discussion and responses unlike any I have seen in a while. To give a little more background as to why I decided to post: I was not to be antagonistic or instigate a storm in a tea cup. It was because for the third time in 2014 I had been told by a notes developer something along the lines of “I can’t learn XPages because I have read that you need to learn Java and I do [read] Keywords: notes xpages blogging community java javascript
715


Why learning JavaScript is more critical to XPage developers than Java
Wed, Mar 26th 2014 5:14p   Mark Roden
I have tried to write this article multiple times over the last 2 years, when I read it back to myself it always sounds like I am bitching. Honestly, I usually am and that is why it has not been published. This is a final attempt at a constructive argument against the insistence on many blogs that everyone should learn Java. Many people think I hate Java; I really don’t. I can program Java (I am no expert admittedly) and have done so on multiple occasions. My concerns are always raised whe [read] Keywords: domino ibm lotus notes notes client R4 xpages ajax application applications community css database development dojo google interface java javascript network server websphere xml




199


PATCHing a Document using Domino Data Service
Mon, Mar 24th 2014 7:11p   Mark Roden
Talk about frustrating – in a week full of slow progress and CORS cross domain hell I found this little annoyance after hours of staring and curing – once again the power of trial and error triumphs over my stupidity again. The problem I have a Domino Data Service running on the server and I want to update a document This is the imaginary URL https://xomino.com/issues.nsf/api/data/documents/unid/FDCA9C28A793D3F785257C4D0068BBCA returning the imaginary data just fine { "@href": [read] Keywords: domino ibm ajax application java server
222


How to ad icons to individual items in a Select2 multi-value field
Tue, Mar 18th 2014 8:08p   Mark Roden
Select2 is one of the best user interface enhancers I have come across – if you do not know what it is then you need to go play with it. It transforms SELECT boxes into dynamic, stunning, interactive UI elements and allows for all sorts of customizations and developer fun. What I want to be able to do is select items from different categories within the select2 box and then add an icon displaying to the user which category they came from. In this article I will show how. Example I want to [read] Keywords: css interface xml
186


My ongoing struggle with stupidity and what is not valid JSON
Sun, Mar 16th 2014 6:06p   Mark Roden
So this was a frustrating lesson to learn – and please feel free to be entertained by my apparent stupidity. I was trying to create my own JSON with an xAgent – seems easy enough. I created a simple output which looked like this { 'items': [ { 'name': 'AK', 'dc': 23 } ] } and when I fed it through my AJAX code it failed. $.ajax({ dataType: 'json', url: "http://copper.xomino.com/xomino/ExtjsBigData.nsf/xState.xsp?query="+query //url: 'http://coppe [read] Keywords: ajax google javascript
208


jQuery in XPages #20 – NProgress – YouTube-like slim progress bar
Wed, Mar 12th 2014 7:02p   Mark Roden
In this article I will describe how to implement and use the jQuery NProgress nano scrollbar plugin Demonstration The XPages integration of NProgress is demonstrated here Download The demonstration database can be downloaded from the link above or from here NProgress Introduction Since Youtube.com added their nano scroll bar at the top of the page there have been a flurry of different jQuery plugins which mimic the nano progress bar at the top of the screen. The silly thing is that the progre [read] Keywords: xpages ajax application applications css database dojo integration javascript openntf server xml




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