332 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Jobs | Twitter | Bookmarks | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Arguably the most dangerous thing you could ever do in XPages – let other people use your eval() in their SSJS
Tue, Jun 18th 2013 157
EXTJS in XPages #12 – Counting categories with Grouped columns
Tue, Jun 18th 2013 76
Editing and testing your XPages CSJS “in real time” using Chrome Developer Tools
Wed, Jun 12th 2013 125
Adding a new browser to the XPages “Preview in web browser” menu
Tue, Jun 11th 2013 161
EXTJS in XPages #11 – Grids with Locked Column(s)
Sun, Jun 9th 2013 134
Getting rid of pointless white space page separators in MS Word
Wed, Jun 5th 2013 127
DCLUG – June 13 – Darren Duke – I Have a Traveler Server – Maybe I Should Secure it Some
Mon, Jun 3rd 2013 156
Top 10
Make your XPages more maintainable – JavaScript Callback functions
Sun, Apr 28th 2013 562
Coolest Error Message ever – Anti-Folder views !
Thu, Apr 4th 2013 461
Server-side HTML vs. JS Widgets vs. Single-Page Web Apps – the XPages version
Mon, May 13th 2013 419
Someone is having a laugh right?
Fri, May 24th 2013 369
Webinar – jQuery: The World’s Most Popular JavaScript Library Comes to XPages – April 23rd
Mon, Apr 1st 2013 354
Domino R9 – now FIPS 140-2 compliant – necessary for doing business with the DoD
Thu, Apr 4th 2013 325
Webcast: jQuery The World’s Most Popular JavaScript Library Comes to XPages – now on YouTube
Fri, Apr 26th 2013 308
DCLUG April 24th – Getting Started with XPages
Wed, Apr 17th 2013 298
Writing a single library for SSJS and CSJS validation – failed attempt #1
Sun, May 19th 2013 293
JavaScript variable hoisting
Wed, May 1st 2013 288


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



Recent Blog Posts
157


Arguably the most dangerous thing you could ever do in XPages – let other people use your eval() in their SSJS
Tue, Jun 18th 2013 7:18p   Mark Roden
In this article I will discuss the power of the JavaScript method eval() and demonstrate how your inappropriate usage of such could bring down your entire organization – yeah it is THAT dangerous…. Introduction In JavaScript the eval() method has long been known as extremely powerful and also extremely dangerous. It turns a string into an executable piece of JavaScript code. It can turn string  into JSON arrays: var str = '[{marky: "genius"}, {brad: "blog monster"}]' eval [read] Keywords: xpages database interface javascript server
76


EXTJS in XPages #12 – Counting categories with Grouped columns
Tue, Jun 18th 2013 5:31a   Mark Roden
In this article I will demonstrate how grouping can be added to the EXTJS grid within your XPage and how the number of rows within that group can be totalled and displayed to the user. EXTJS in XPages series Here are links to all of the previous articles in this series EXTJS in XPages #11 – Grids with Locked Column(s) EXTJS in XPages #10 – Grid Row Expander plugin EXTJS in XPages #9 – Infinite scrolling rebooted and reborn – v4.2 BufferedRenderer EXTJS in XPages #8 – Selecting data fr [read] Keywords: domino notes xpages database
125


Editing and testing your XPages CSJS “in real time” using Chrome Developer Tools
Wed, Jun 12th 2013 2:23p   Mark Roden
In this article I will demonstrate how you can make live changes to your CSJS using firebug and chrome deveveloper tools and figure out where your bugs are happening before committing them to your XPages database. Introduction  First rule of thumb – put as much of your XPages Client Side JavaScript (CSJS) in a JavaScript script library as possible. The reasons are compelling and simple: Separation of code makes for much easier maintenance Changing CSJS libraries required a CTRL-F5 to v [read] Keywords: ibm script library xpages application database javascript xml
161


Adding a new browser to the XPages “Preview in web browser” menu
Tue, Jun 11th 2013 3:06a   Mark Roden
I wanted to add Chrome to my list of browsers which I could preview my XPages in and I went digging in the preferences and found out how in File > Preferences under the general section there is a “Web Browser” option where you can add a new one Then I had to find where Chrome was installed (obviously change UserName to your own path) C:UsersUserNameAppDataLocalGoogleChromeApplicationchrome.exe Added it and there you have it – now in my menu [read] Keywords: xpages application google
134


EXTJS in XPages #11 – Grids with Locked Column(s)
Sun, Jun 9th 2013 6:51p   Mark Roden
In this article I will highlight a grid column property which allows the developer to lock the columns on an EXTJS grid in a similar fashion to freezing a frame in excel. EXTJS in XPages series Here are links to all of the previous articles in this series EXTJS in XPages #10 – Grid Row Expander plugin EXTJS in XPages #9 – Infinite scrolling rebooted and reborn – v4.2 BufferedRenderer EXTJS in XPages #8 – Selecting data from the grid and opening a document EXTJS in XPages #7 – Doing an [read] Keywords: xpages database
127


Getting rid of pointless white space page separators in MS Word
Wed, Jun 5th 2013 2:17p   Mark Roden
Thank you Simon Reid ! You are looking at a word document and it is a pain to move from one page to another because of the margins and a separator between each page Simple fix – mouse over the separation and double click How did I not KNOW ABOUT THIS?? And even better with short pages with a break in them Productive !! [read] Keywords:
156


DCLUG – June 13 – Darren Duke – I Have a Traveler Server – Maybe I Should Secure it Some
Mon, Jun 3rd 2013 10:31a   Mark Roden
This month we are delighted to welcome Darren and Lisa Duke of STS Inc. in Atlanta who are travelling to DC to present at the meeting ! Not only is Darren one of the most recognized names in the IBM Notes Domino community he is also a really entertaining speaker. Even if you are not into Traveler, you should definitely come, be entertained and learn something new. For more information on Darren – check out his linkedin page and if you want to talk Traveler while him and Lisa are in town &# [read] Keywords: domino ibm lotus lotusphere notes traveler bes blogger community google iphone linkedin podcast security server
97


OpenNTF Webinar – Getting Started with XPages – Tomorrow – 06-04-2013 10:00 EST
Mon, Jun 3rd 2013 9:19a   Mark Roden
Tomorrow I have the honour of speaking with my mate Dave Leedy and presenting the second in the OpenNTF webinar series - Getting Started with XPages Dave and I are going to go through a lot of information in a short period of time. The intention is to make the transition to XPages seem less scary, provide you information you need to know when making the transition and help you through the process. This conversation is open to all developers of all skill levels and I encourage community members [read] Keywords: domino ibm xpages community openntf password




188


Writing a single library for SSJS and CSJS validation – first success
Wed, May 29th 2013 6:49p   Mark Roden
The other day I wrote about my failure to realize that CSJS and SSJS libraries shalt not cross  during my attempt to write a single library for CSJS and SSJS validation code. Not to be out done and with some great suggestions from the wonderful Sven Hasselbach I trucked on into the next attempt. Parameterized development I first met this concept a few years ago. I was working on an application created by John McCann, and all the script routines for a suite of applications were sorted in notes [read] Keywords: domino lotus notes script library application applications database development firefox java javascript password security server xml
189


The original DBIcon image path is stored in the database
Tue, May 28th 2013 7:37a   Mark Roden
I noticed the following as it popped up in my DDE search for “iPad” – something just to be aware of. Don’t upload the DBIcon from a path you would consider inappropriate – it remembers [read] Keywords: database




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