Computed hidden Columns
Posted by Theo Heselmans on September 19th, 2007
My customers love the 'Customize This view' feature in Notes (that is, after I tell them it exists). But sometimes you, as a developer, want to be more in control. I recently had to make a view, where each user could turn on and of view columns, using a 'toggle' button. I played around with a couple of techniques, but in the end settled for the following solution.
This is an example of how it looks initially:
When the user clicks either of the 'Quarter' buttons, this is the result:
Of course in reality there's only 1 button, but I wanted to test the 'Checkbox' action too (I don't use it a lot though).
The code behind both buttons is exactly the same:
Dim s As New notessession
Dim ws As New NotesUIWorkspace
If s.GetEnvironmentString("ShowQ")="1" Then
Call s.SetEnvironmentVar("ShowQ","")
Else
Call s.SetEnvironmentVar("ShowQ","1")
End If
Call ws.ViewRebuild
End Sub
As you can see, the code just toggles the environment variable 'ShowQ',
and in the end does a rebuild of the view.
Now, I'm not happy with the view rebuild because of 2 reasons:
- This will impact a view with many docs
- It does not work when the user has no designer rights
It is major overkill to rebuild the view.
Of course, the 'hide when' formula for the 4 Q-colums is the same:
The formula for the label of the Show/Hide Quarter button goes like this:
@If(@Environment("ShowQ")="";"Show";"Hide")+" Quarters"
The result is what the customer wanted, but as I said, I don't like my solution.
You have a better idea, let me know.
Category: Domino/Notes | Technorati: Show-n-Tell Thursday, SnTT
Comments (3)
Another "trick" is to switch the view with another when the user clicks the button. This way, you don't need to rebuild the view.
If the change is to be persistent, compute the outline entry/etc, that opens the view, based on the @Environment-var.
onClick (you may need @SetTargetFrame):
@If( @Environment( "ShowQ" ) = "view1";
@Environment( "ShowQ" ; "view2" );
@Environment( "ShowQ" ; "view2" )
)
@Command([OpenView] ; @Environment( "ShowQ" ) )
I have done quite the same thing, but with profile document. It is a financial application, so people have a profile where they can store their preferred currency (choice of 3 only), and having the ExRate stored on each document I have 3 columns that each are hidden if the currency is the one chosen or not.
However, the profile change is not an action bar option, it's in the page (2 page frameset) and the code ends with a Call W.ReloadWindow
Although the DB has quite a lot of document, This doesn't seem too bad in performance.
I would not even think you need to "Rebuild" the view, columns are there but hidden. In my mind, Notes has them stored in its index.
Hope this helps :)
I am usually using the solution proposed by Tommy but I quite like your one as it prevents me from maintaining two views.
I have tested that and I have to say that although the need of view rebuild is a nuisance it works for me even if I do not have a designer access.