|
|||||||||||||
BackgroundIn a previous article we have seen, how to adapt or improve the layout of a view for browsers with stylesheets (css). See: Further improve your Domino views on the Web. In this example we used as much as possible of the domino integrated web engine. We got the intended results just by adding a stylesheet. In 95% of all cases the outcome fulfills all our requirements. But in some cases we need a little bit more control. Domino generated views layout can not fulfill all our requirements. For instance we like to define the width of the columns with pixel precision an we expect that every browser displays and renders the page as accurate as possible. See how we do it: RequirementsTo define the width of our columns we use the
"<colgroup>" tag between the "<table>"
tag and the first row-tag "<tr>". <table> More information about The
COLGROUP element you can find at w3.org:
And within both, the form and the view, we must write the html code: $$ViewTemplate content 1:<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" Line 1: Tells the browser to which kind of html we stick. Line 2: With the link to the DTD we tell the browser to work in Standards compliance mode. Lines 3, 4, 10, 11, 22 and 23: Are standard tags of a html page. Lines 5,6,7: Not imperatively required, but telling the browser what we'll send, makes our life easier, by avoiding bad surprises. Line 8: Includes our stylesheet. The computed text "<computed Value>" with the Formula : "/"+@Unique(@ReplaceSubstring(@Subset(@DbName;-1);"\\":" ";"/":"+"))+"/" makes our Notes-DB position independent. Line 9: With the title we put some publicity on our "roof" and don't care if people take note or not. Line 12: Now the interesting things starts! This is the table opening tag. Line 13 to 19: Between the opening and closing colgroup tags, we define the column width by pixels for each column in our view. Line 20: The Field $$ViewBody of type "Computed for display" with the content "" (empty) is the link to our view. Note: Alle table tags like <tr>, <th> and <td>, etc. are generated by the view, see below. Remark: Strictly speaking, the real link is the name of the form "$$ViewTemplate for view-Alias-name", where view-Alias-name must correspond exactly to the alias name of the view! Line 21: Closing tag of the table, and for the form we are done. View contentIn our example we have 5 columns with the headers:
Each column label must be set between an opening and a closing tag "<th></th>" and the header row requires an opening and a closing tag <tr></tr> the latter two we write in front of the first column, and at the end of the last column respectively. The following line shows how it must look like:
Alternative: You are free to define the above line within the $$ViewTemplate form (between lines 19: and 20:) and check "Do not display Title in column header" for each column in the view. Now each column requires a Formula. In our case, each field name is set between tags: "<tr><td>"+FirstName+"</td>" "<td>"+Name+"</td>" "<td>"+@Text(@Date(Date))+"</td>" "<td>"+Department+"</td>" "<td>"+email+"</td></tr>" The first column gets the additional row opening tag, and the last column the corresponing closing tag. That's it! Remark: The tags are pure text, that's why me must convert dates or numbers to text first, to avoid incorrect data arrors. For your convenience you may download the zipped nsf-DB ** with the
fully working examples. Download test CSS DB |