SnTT.jpgMy 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:
Image:Computed hidden Columns
When the user clicks either of the 'Quarter' buttons, this is the result:
Image:Computed hidden Columns
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:

Sub Click(Source As Button)
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
I can't find a better solution that will reflect the changes ad hoc.
It is major overkill to rebuild the view.

Of course, the 'hide when' formula for the 4 Q-colums is the same:
Image:Computed hidden Columns
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  | TechnoratiTechnorati: ,