By Colin Neale
Create a simple database
I started by creating a database. I added a form and two fields: "Title" and "Author". Next I added some sample documents. Figure A shows these documents when viewed from the Notes Client.FIGURE A
Here's a simple database contents viewed in Notes. (click for larger image)
Here sorting is achieved by clicking on each column header. I will now show you how to reproduce this same functionality in the browser.
Create a Web view
I proceeded to create a view for the browser. I used multiple columns to make the code easier to follow but you could group all of the HTML into a single column if you prefer. Each column in my Web view is detailed below. The Column-1 formula is simple:
Set to sorted ascending and hidden because we don't want the browser to see it. The Column-2 formula has some table tags:
This defines the start of each table row. Note that I have given the row a "title" attribute. I use title attributes of the "tr" and "td" tags to give me access to the data that I want to sort on.
The Column-3 formula is where some of the hard work begins:
_url := _db + "/0/" + @Text(@DocumentUniqueID) + "?OpenDocument";
"<td width=\"50%\" title=\"booktitle\" abbr=\"" + @UpperCase(Title) + "\"><a href =\"" + _url + "\">" + Title + "</a></td>"
This is the first column of the HTML table. It displays the book titles as links. Note, that I use the "title" attribute of the "td" tag here just as I did for the "tr" tag above. For the table columns however I also use the "abbr" attribute to hold the value that I wish to sort by.
Column-4 formula adds a bit more:
The second table column displays the value in the Author field.
The Column 5 formula ends the table row:
Finally, I enabled the "Treat view contents as HTML" property and saved the view.
Create a form to show the view through
Next I created a $$ViewTemplateDefault form to display the view created above. I added the following HTML code to the top of the form.