Search DominoPower's 11,320 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
PROGRAMMING POWER
Sorting your Domino views with JavaScript
By Colin Neale

Have you ever wanted to be able to sort your Domino views in the browser in just the same way that you can from the Notes Client? This article shows one way to achieve column sorting on the Web using some simple JavaScript routines. I use a similar method to allow the sorting of search results in my C-Search products.

Create a simple database
I started by creating a database. I added a form and two fields: "Title" and "Author". Next I added some sample documents. Figure A shows these documents when viewed from the Notes Client.

FIGURE A


Here's a simple database contents viewed in Notes. Roll over picture for a larger image.

Here sorting is achieved by clicking on each column header. I will now show you how to reproduce this same functionality in the browser.

Create a Web view
I proceeded to create a view for the browser. I used multiple columns to make the code easier to follow but you could group all of the HTML into a single column if you prefer. Each column in my Web view is detailed below. The Column-1 formula is simple:

Title

Set to sorted ascending and hidden because we don't want the browser to see it. The Column-2 formula has some table tags:

"<tr title=\"row\">"

This defines the start of each table row. Note that I have given the row a "title" attribute. I use title attributes of the "tr" and "td" tags to give me access to the data that I want to sort on.

The Column-3 formula is where some of the hard work begins:

_db := "/" + @ReplaceSubstring(@Subset(@DbName;-1);"\\";"/");
_url := _db + "/0/" + @Text(@DocumentUniqueID) + "?OpenDocument";
"<td width=\"50%\" title=\"booktitle\" abbr=\"" + @UpperCase(Title) + "\"><a href =\"" + _url + "\">" + Title + "</a></td>"

This is the first column of the HTML table. It displays the book titles as links. Note, that I use the "title" attribute of the "td" tag here just as I did for the "tr" tag above. For the table columns however I also use the "abbr" attribute to hold the value that I wish to sort by.

Column-4 formula adds a bit more:

"<td width=\"20%\" title=\"author\" abbr=\"" + @UpperCase(Author) + "\">" + Author + "</td>"


1  ·  2  ·  3  ·  Next »
Other articles you might like
Home > Internet Technologies > JavaScript (13 articles)
   Give your Domino views life with DHTML
   Using dynamically generated HTML to thwart spam email address harvesting
   Implementing dynamic drop-down menus using Domino and Internet Explorer
Home > Lotus Technologies > Domino (77 articles)
   More about Domino log files
   Why your log.nsf might not be purging properly
   Sloppy analysis at the core of another Domino vs. SharePoint report
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Five trends for 2010
DominoPower TV Episode 1: Inside a strategy session with Teamstudio
More about Domino log files
Say goodbye to the Uh-Ohs. Long live the Tens.
Why your log.nsf might not be purging properly
Latest Lotus Headlines
SnTT: XPages Blank Calendar Control (Part 2), adding data
Have your Lotus Notes calendar display multiple time zones
Sample Database for Microsoft Office and Lotus Symphony Integration
Symphony 3.0 beta signals another attack on Office
Enabling DAOS on a database - new recommendation
Need your opinion on some new policy settings for Mail
Sometimes IBM Lotus Domino HTTP RPC Agents aren't the answer...
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad: Apple's latest heartbreaker
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Running auto-respond rules when Outlook is closed
-- Advertisement --

Power Tools 6.0 is a set of 90 administrative utilities for Lotus Notes & Domino
Power Tools simplifies management of the Notes/Domino environment by automating routine tasks. Power Tools can manage or monitor mail files, groups, ACLs, agents, LOG.NSF, templates and more.

Download a trial version from helpsoft.com.
-- Advertisement --

Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.

Register by December 31 to save $350.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login