SearchDomino.com
June 25, 2001
Developer Tip
================================================= 
------------------------------------------------- 
Sponsored By: ONLINE CORPORATE SOFTWARE
------------------------------------------------- 
*********** WIN AN IBM THINKPAD T21 *************  
Online Corporate Software is giving away a brand new IBM Thinkpad
T21.  To enter the draw just visit our Website and complete the
trivia quiz.  With over 35 open source code Lotus Notes applications
and free online Notes technical support OCS is fast tracking Domino
development. http://www.onlinecorporatesoftware.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
*************************************************
SPECIAL NOTICE: SearchDomino to reach a membership of 100,000 Notes
and Domino pros! 
*************************************************
In recognition of this milestone, we want to give YOU and a colleague
a limited edition searchDomino denim shirt. Here's how to win:

1. Click the link below
2. Enter your e-mail address on our "Email a friend" page
3. Enter the e-mail address of a peer who is not already a member of
searchDomino. 
4. Lastly, in the "Comments" box ask your colleague to register for
FREE on searchDomino - and have them enter your e-mail address or
name in the "Promo Code" area of the reg. page. That's it!

We'll identify both our 100,000th member (soon!) along with the
person who helped them to register - then you both get a FREE denim
shirt! Plus, your names will be announced to members when we hit the
100,000 milestone. Click here and enter to win!
http://searchdomino.techtarget.com/emailAFriend

================================================= 
Feature Tip
================================================= 
Title: Display more documents in the same row on a Web view
This tip was submitted by Filippo Del Prete in Ancona, Italy.
http://searchdomino.techtarget.com/tip/1,289483,sid4_gci557648,00.html

This tip shows how to display more documents in the same row on a Web
view.

You have a set of documents

Doc1
Doc2
. 
. 
Doc(N-1) 
DocN

Suppose you want display these documents in a Web view in this format
(a 3 column view) 

Doc1    Doc2    Doc3
Doc4    Doc5    Doc6

. . . 

Doc(N-1)     DocN

Suppose you don't know the total number of documents. 

You need some HTML and some JavaScript. 

This is my solution: 

You have a view View001 and the form $$ViewTemplate for View001
The View001 has the attribute "Treat view contents has HTML" set. 

In this view, I put one column with this value: 

"<script language="JavaScript"> " + @Char(13)+ 
" var conta=" + @DocNumber("") +" % 3;"+ @Char(13) +
"if (conta == 1) {" + @Char(13) +
"document.write("<TABLE><TR>");" + @Char(13) +
"}" + @Char(13) +
"</script>"+ @Char(13) +
"<td width="33%"> 

...Put here the HTML data formatting and HREF for your document... 

</td>" +@Char(13) +
"<script language="JavaScript"> " + @Char(13)+ 
" indice = indice + 1;"+ @Char(13) +
"if (conta == 0) {" + @Char(13) +
"document.write("</TR></TABLE>");" + @Char(13) +
"}" + @Char(13) +
"</script>" + @Char(13) 

Some explanations: 

We want an HTML table like this: 

<TABLE><TR><TD WIDTH="33%"> Doc1 </TD><TD 
WIDTH="33%"> Doc2 </TD><TD WIDTH="33%"> Doc3 
</TD></TR></TABLE> 
<TABLE><TR><TD WIDTH="33%"> Doc4 </TD><TD 
WIDTH="33%"> Doc5 </TD><TD WIDTH="33%"> Doc6 
</TD></TR></TABLE> 

and so on. 

In the top JavaScript section, we have to know if we start a new
table or if we are inside the table. So we use the formula function
@DocNumber to print the sequence doc number N inside the JavaScript. 

Then the browser will evaluate the statement with the modulo
function. 
var conta = N % 3; 

We will know if we have to start a new HTML table to display a new
row. 
We do so checking the variable "conta." 

if (conta == 1) {
document.write("<TABLE><TR>"); 
}

In the bottom JavaScript section in the same way we have to close the
HTML table at the right moment: 

if (conta == 0) {
document.write("</TR></TABLE>"); 
}

In this section, you noticed that I used a new variable indice
indice = indice + 1; 

I need this variable declared in the $$ViewTemplate for View001 form
because we don't know the total documents number. 

And so in the $$ViewTemplate for View001 form I put some Pass-thru
HTML text before the $$ViewBody field: 

<script language="JavaScript"> 
var indice = 0; 
</script> 

Indice is a global JavaScript variable that we increment for every
document in the view. 

After the $$ViewBody field, we have to put the right HTML to
correctly close the TABLE structure. 

<script language="JavaScript"> 
if (indice % 3 == 1) {
document.write("<TD></TD><TD></TD></TR><
/TABLE>") 
}
if (indice % 3 == 2) {
document.write("<TD></TD></TR></TABLE>") 
}
</script> 

We don't need to check indice = 0 because we have already done this
control in the column view. 

I used two different variables (conta and indice) for my personal 
purposes, but you can use just the global variable indice without the
@DocNumber("") function. You will have better performance. 

END CODE

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 

Do you have a comment or additional code for Web views?  Jump into
our Developer Discussion forums and toss your ideas around with your
peers:
http://searchdomino.discussions.techtarget.com/WebX?50@@.ee7740b

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
NEWLY POSTED DEVELOPER TIPS: 
================================================= 
We posted 17 new tips last week. Thanks for all your tips and keep
them coming!

Agent Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283834_alpD_idx0,00.html

[1] Restrict shared agents
[2] How to fix a corrupt BUSITIME.NSF automatically

Domino Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283837_alpD_idx0,00.html

[1] Using the Admin Client on the Domino Server without installing it

Formula Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283836_alpD_idx0,00.html

[1] Open to a Form Using @functions
[2] Reference a value from a column in a view
[3] Avoid hard coding a database path
[4] Elapsed Time 

HTML Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283838_alpD_idx0,00.html

[1] Reusing a document without clearing a hidden field 
[2] Multi-line text fields on the Web

JavaScript Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283840_alpD_idx0,00.html

[1] Select or deselect documents in a mail database
[2] Update non-editable fields in browser

Other Category:
[1] Embed a Macromedia Flash Movie Clip into a Domino Designer Page
[2] Appending embedded attachments in a document into a richtext
field
[3] Linking to Notes from Word Document
[4] How to get rid of "No documents found"

Script Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283841_alpD_idx0,00.html

[1] Propagate status changes to children documents
[2] @Adjust in LotusScript

================================================= 
FEATURED BOOK:
================================================= 
Notes and Domino R5 Developer's Guide to Building Applications    
By Matt Riggsby

Notes and Domino provide the technology to solve pressing business
problems. But you have to provide the know-how, and this book gives
you just that--the hands-on knowledge you need to put the powerful
features of R5 to work in effective, fine-tuned solutions that
improve the way your organization shares information.

http://www.digitalguru.com/dgstore/product.asp?sku=0782128246&dept%5Fid=288&ac%5Fid=60&accountnumber=&couponnumber=

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
------------------------------------------------- 
JUNE'S TIP PRIZE!
------------------------------------------------- 
Will you be sporting the Secret Agent Man Digital Watch?  This watch
isn't just a watch, it's a high-tech digital device that has
everything you'd ever want in a watch and more. Some of the
innovative features include:  *Storage of up to 100 internet/email
addresses, phone numbers or other memos *3 alarms  *Self-adjusting
calendar  *Water resistance up to 100 meters  *Optional vertical or
horizontal display *Random message feature with 45 preprogrammed
greetings *A retail value of $200.  Submit a Developer tip in June,
and let's see if you can be the latest Secret Agent Man.

http://searchdomino.techtarget.com/tipsContest/0,289488,sid4_prz546242_cts546237,00.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Disclaimer: These tips are submitted by your Domino peers. Our tips
services and online tips exchange are a way for you to learn from
other IT professionals and share technical advice and expertise with
your peers. Techtarget.com provides the infrastructure to facilitate
this sharing of information. However, we can't guarantee the accuracy
and validity of the material submitted. You agree that your use of
the searchDomino.com tips services and your reliance on any
questions, answers, information or other materials received through
searchDomino.com will be at your own risk.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
NOTIFY US WITH FEEDBACK  
================================================= 
Send us your tips feedback! Cast your vote and send us your tips
comments.  If you have vital code information or other comments you'd
like to add to one of our online tips, send your comments to
[EMAIL PROTECTED], and we'll add your User Feedback to the
online tip!

================================================= 
If you would like to sponsor this or any TechTarget newsletter,
please contact Gabrielle DeRussy at [EMAIL PROTECTED]

================================================= 



If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://searchDomino.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to