|
Written by Bruno Grange
|
|
Wednesday, 03 September 2008 02:07 |
|
In a Lotus Notes view, you can easily set colors to rows based on category, but only if the categories are known. If the categories are unknown or dynamic, setting the row colors by category gets trickier. Here's how to accomplish it.
- Create a Lotus Notes view named 'ColorP.' Add a sorted, categorized column for the value you categorize in the document. In this case, let us say DDHID is the field you want to categorize on. In the last tab of the column properties, type DDHID in Programmatic Use Name. Use the same view selection formula as you would keep for the main view (call it 'Main View') displayed to the user.
- Create a profile document and name it "WebLogProfile" form.
Create the four fields as follows:
Sender1B (Color type, Editable), Sender1F (Color type, Editable), Sender2B (Color type, Editable), Sender2F (Color type, Editable)
Create a field named 'List2Field' as computed -- do not make it multi-value.
Add the following formula:
database := @Subset(@DbName; -1); server := @Name([CN]; @Subset(@DbName; 1)); Sender1List := @Sort(@Unique(@Trim(@DbColumn ("";server:database; "ColorP";1)))); GetSenderList := """ + @Implode (Sender1List; "":"") + """; GetSenderList
Add a second field '$color1' as computed -- do not make it multi-value.
Add the following formula, don't worry about tmpColorButton, it is a temporary variable:
@If(tmpColorButton = "1"; ""; "S_1B := "" + Sender1B + ""; S_1F := "" + Sender1F + ""; S_2B := "" + Sender2B + ""; S_2F := "" + Sender2F + ""; colr1 := S_1B : S_1F ; colr2 := S_2B : S_2F ; @If(@Modulo(@Member(DDHID ; " + List2field + ") + 1; 2) = 0 ; colr1;colr2 )")
- Create a view named 'Main view,' this will be shown to the user.
Add the first column as a hidden column, then select "use value as color" and "User Definable." In the Profile Document: "WebLogProfile." In the last tab of column properties under Programmatic Use Name {type}:
$color1 ( check Hide column) In the column formula: @Trim(DDHID)
- Edit the "WebLogProfile" document and select colors for Sender1B, Sender1F, Sender2B, Sender2F. Save this and close the document.
- You may need to refresh the WebLogProfile document somehow (any way you want in the backend). Here is an example in LotusScript:
set profiledoc = db.Getprofiledocument("WebLogProfile") success = profiledoc.Computewithform(False, False) if success then call profiledoc.Save(TRue, TRue)
Endif
- Verify that the alternate color is shown per category. Remember, you may need to close and open the view in order to refresh the color.
Related Articles: |