Friday, October 20, 2006

Quick Tip: Simulating A "Frozen" Column

Disclaimer: This posting might be more academic in nature than anything else, since it might not be a very practical solution. However, depending on your needs, this might be a neat little hack you can implement in your own application.

I was asked by a user if I could basically "freeze" a column, similar to the function available in Excel. If you do this in Excel, you can scroll horizontally while your frozen columns stay fixed in place. This is a great feature when you have information in many columns, but want to keep the key value in view as you scroll. Unfortunately, Notes does not offer this option in views. I thought it might be possible to simulate this using column hide-when properties. What I came up with was good enough to satisfy the users, so I thought I'd share with the rest of the class. Here's the low down:

I created a couple of action buttons that control the "scrolling". The actions are used to set an environment variable to either "True" or "False" and this environment variable is checked in the hide-when formula for the columns I want to hide. In the case of my application, I basically wanted the four columns to the right of my first column to disappear if the user "scrolled" right. I would reverse the procedure to allow them to "scroll" the other direction. Since hide-when formulas for a view are evaluated only when the view is initially rendered in the Notes client, you have to either close and reopen the view or rebuild it. Just because I hate trying to close and open elements within frames, I chose to rebuild the view. The code for the action button then is very simply:

Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession

Call session.SetEnvironmentVar("ItemMasterScrollLeft", "True") 'set to false to reverse
Call workspace.ViewRebuild

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

And for each column that should be hidden when scrolled, the hide-when formula becomes:

@Environment("ItemMasterScrollLeft") = "True"

Simple as pie! :-)

The pic below shows the feature in action. The hide-when feature of columns can be pretty useful, so don't forget it when designing your UIs.

Have a great weekend everyone!


By Anonymous Nathan T. Freeman, at 12:04 PM  

Great technique and great use of column hide-whens!

By Anonymous Nathan T. Freeman, at 12:05 PM  

Oh, and I'm thrilled to see you're reading Ender's Game. Card is a genius, that that's one of my all-time favorite books.

By Anonymous thorne ventura, poughkeepsie NY, at 2:59 PM  

Unfortunately setEnvironmentVar only works if users have the authority to run agents on the server. Any alternate solution?

By Blogger Chris Blatnick, at 7:33 PM  

@Thorne: Since this script is running on the local machine, it is setting the value in their Notes .ini. Those restrictions are if the script is running on the server. From the Notes help:

"If a script runs on a workstation, the user's environment variable is set. If a script runs on a server, the server's environment variable is set, subject to administrative restrictions."

I've successfully used this code in many applications. As long as it's not in a scheduled agent, you'll be good to go.

Post a Comment

Links to this post:

Create a Link

<< Home