359 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Simple examples of how Google Developer Tools can aid Mobile Development
Thu, Oct 30th 2014 132
Binding jQuery code to an XPages partialRefresh using DOM Mutation events
Wed, Oct 29th 2014 218
Using jQuery .when() to trigger a screen update after select2 has loaded
Tue, Oct 28th 2014 123
Integrating the Bluemix Watson Translation service into an XPages application
Sun, Oct 19th 2014 349
Oh duh, that is why Node Package Manager (npm) is so cool
Tue, Oct 14th 2014 338
Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 760
Getting into IBM Bluemix….this could be interesting
Wed, Oct 8th 2014 269
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 1284
Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 760
Running an XPages/Angular.js application on a Bluemix site
Wed, Sep 17th 2014 558
Going to MWLUG 2014? Buy Dave Leedy a beer
Sun, Aug 24th 2014 451
Angular.js in XPages #7 – Writing better code using Services
Sun, Aug 3rd 2014 428
EXTJS in XPages #13: Totaling your columns with a groupingSummary
Sun, Jun 30th 2013 410
Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 402
Taking back productivity in Domino Designer (a NotesIn9 production)
Tue, Jul 29th 2014 395
Hi Chicago – what changed?
Wed, Jul 2nd 2014 374
Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 349


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



Recent Blog Posts
132


Simple examples of how Google Developer Tools can aid Mobile Development
Thu, Oct 30th 2014 7:36p   Mark Roden
In this article I will show some simple examples of how Google Developer Tools can be used to help in mobile (responsive) development. Introduction Google Developer Tools (F12) within Chrome is one of those things which you *know* is way more powerful that you have ever cared to look at but this week I was introduced to a very cool new feature – thanks to @simonreid123. The ability to control the veiwport and size of the viewing window, as well as being able to throttle the speed of page [read] Keywords: development google iphone mobile network twitter
218


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. Background 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 xpages application css dojo server
123


Using jQuery .when() to trigger a screen update after select2 has loaded
Tue, Oct 28th 2014 5:58a   Mark Roden
We have an XPage with over 100 complex fields on it and we found that applying Select2 to it took a noticeable amount of time – tangible to the user. Users would see the original “SELECT” fields before the nicer select2 style was applied. So we determined to hide all the fields on the form until select2 was finished loading, then show them all select2’d. The problem was that would could not find an obviously way to do this. I was looking for a parameter within the s [read] Keywords: xpages css
349


Integrating the Bluemix Watson Translation service into an XPages application
Sun, Oct 19th 2014 7:07p   Mark Roden
In this article I will demonstrate how to integrate the Bluemix Watson Translation service into a functioning XPages application. Bluemix Watson Translation Service Following on from one from my previous posts on the subject I have been looking for a good workable example of using a Bluemix service within an XPages application. As I said before this is as much an exercise in me learning more about node.js and Bluemix as anything else – but I also love being able to share. Based on the [read] Keywords: domino ibm notes xpages ajax application development server xml
338


Oh duh, that is why Node Package Manager (npm) is so cool
Tue, Oct 14th 2014 9:07p   Mark Roden
I am in the process of playing with Bluemix and part of the reason or this is to learn more about node.js. It is really cool to learn something new and also to broaden the mind. But I digress – Node Package Manager (npm) makes using node.js so simple it is mind boggling… Without going into masses of detail on node.js (which I might at some point) here is the simple example of what I am trying to do and why npm is so cool. Node Package Manager (npm) allows you to install any node [read] Keywords: application applications interface
760


Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 10:19p   Mark Roden
Introduction In this article I will demonstrate how to get up and running with one of the Bluemix/Watson service examples. I will be using the example provided by IBM in their documentation as the basis for the article but the way in which I achieved the final goal was quite different from the way that they explained it in the example. This example will use: IBM Bluemix as my service provider The Watson Question and Answer service A Node.js service to host the website JetBrains Webstorm IDE [read] Keywords: domino ibm application css integration javascript password server




269


Getting into IBM Bluemix….this could be interesting
Wed, Oct 8th 2014 7:12p   Mark Roden
My interest in IBM Bluemix has grown since it was announced. I took part in the Beta, but frankly didn’t do very much because I really couldn’t figure out what it was or why I cared. Since then though IBM has announced that they are investigating putting Domino into Bluemix. Before I start down this path I have to say at this point that I have no idea what “Domino in Bluemix” even means. I have no idea what that will look like and while I would love to second guess a [read] Keywords: domino ibm xpages application applications development interface java mobile server
199


Opening an XPage in XPiNC and passing Query_String parameters
Tue, Sep 30th 2014 7:22p   Mark Roden
I was very pleasantly surprised to find this works – coincidentally – twice this week someone has asked this question – can I open an XPage in XPiNC directly? I thought the answer was no……and not for the first (and/or last) time I was wrong. The answer lies here – http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Domino_Designer_URLs_for_XPages To prove it I created a plain XPage and added the firebugLite custom control The following XPiNC URL notes://copper/882579C [read] Keywords: ldd lotus notes
271


Closing soon: IBM Domino/Notes Community Survey
Mon, Sep 29th 2014 11:12a   Mark Roden
For the last two weeks PSC has been asking for input from the ICS community on what companies are planning on doing with their Domino Infrastructure. If you have not already done so, please take a couple of minutes to help. The results will be posted next week. http://bit.ly/PSCXPagesSurvey [read] Keywords: domino dominonotes ibm notes community
236


What is a social presence worth?
Sun, Sep 21st 2014 7:51p   Mark Roden
We had an interesting discussion internally at work about what exactly does our “Social Presence” do for us? I put time and thought to it and it turns out to be a question I can answer on many levels. I am still not entirely sure what the answer is. What does being social mean? Being social means sharing through ideas, code, concepts, dreams….anything really – but sharing it. Within the XPages community we have a multitude of people who are social for many different r [read] Keywords: domino ibm xpages community development java office sharepoint




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