OpenNTF.org - AJAX NotesView for Web
    Advanced
   OpenNTF Code Bin
Edit Document Code By Date > Code Document
About This Code
Brief Description:
AJAX NotesView for Web 
Rating:
Rating: 5 , Number of votes: 3 
Contributor:
jason a thomas 
Category:
Javascript 
Type:
Webdevelopment 
Notes Version:
R6.x, R7.x 
Last Modified:
19 Jun 2007 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Usage / Example
simplest implementation:
var oView = new NotesView2( 'relative web path to database', 'name of view');
oView.render(<js object handle to html element to render view into>);


more complex:
oView = new NotesView2(DB_NAME,VIEW_NAME); //create the view object

//set some extra parameters (optional)
oView.hideSelectionMargin = false;
oView.openDocument = function(viewEntry){
document.location.href = DB_NAME + "/" + VIEW_NAME + "/" + viewEntry.unid + "?Opendocument";
}
oView.actionButtonDisplay = 3;
oView.linesToShow = 15;
oView.linesToGet = 30;
oView.addAction("Expand All", function(){oView.expandAllEntries()});
oView.addAction("Collapse All", function(){oView.collapseAllEntries()});
oView.addAction("Refresh", function(){oView.refresh()});
oView.addAction("Jump To", function(){oView.jumpTo()});
oView.addAction("Search",function(){oView.toggleSearchBar();});


//render the view to the page (see HTML Head Content for CSS styles and class names)
oView.render(document.getElementById('viewHolder'));
Code Attachments
viewdemo.nsf (384 Kbytes)
viewsample.JPG (31 Kbytes)
 Comments
Posted by Patrick Kwintensson on 05/14/2007 02:49:16 AMwhat am I suppose to see?
I only get to see:
SAMPLE - Cars
(I have run the agent, so documents are visible in Notes client)
Posted by jason a thomas on 05/14/2007 09:42:27 AMRE: what am I suppose to see?
You should see the view underneath the view title.
This should work in Firefox 2 and IE5.5+ (definitely 7, which is what i'm running). I haven't tried Opera or Safari. Are you testing it locally? It does need to be on a server for the AJAX calls to work.
If you see nothing below the view title, then there must be a javascript error firing before the view gets drawn to the page. If you change your browser to show javascript errors then maybe you could post any error messages you receive.
Posted by jason a thomas on 05/14/2007 09:57:04 AMno R5?
I just did a quick search and this code may not work with R5 after all. I don't have access to an R5 server but I think the ?ReadViewEntries and ?ReadDesign xml may be formatted differently somehow. I'll have to look into this.
Posted by Patrick Kwintensson on 05/14/2007 10:22:54 AMError 404 HTTP Web Server: Lotus Notes Exception - File does not exist</body>
Okej I first did not run it on a server, but now I do I get in Firebug the message
GET http://test.server.com/ds01232%0Biewdemo.nsf/SAMPLE%20-%20Cars?readdesign404 (16ms)
While the address should be:
http://test.server.com/ds01232/viewdemo.nsf/SAMPLE%20-%20Cars?OpenView
so there it goes wrong...
Posted by jason a thomas on 05/14/2007 11:33:00 AMUpdate
Patrick, I just updated the viewdemo.nsf database attached to this, so give it a try. I think it was a bad piece of Formula language on the sample form that was causing problems for you.
Also, in R5 vs. R6+ there are case-differences in the XML tags so I made the xml parsing case-insensitive so this should work with R5 now, although I have no way of testing.
Posted by Karen Demerly on 05/15/2007 01:19:15 PMNice
I only took a quick look, but it looks nice, Jason. I'd be curious to hear what's on your list of possible enhancements. Maybe share it and let us vote? ;-)
Thanks for sharing what you've got so far.
Posted by jason a thomas on 05/15/2007 11:13:35 PMRE: Nice
Thanks Karen,
Some things I'd like to add:
- resizable column widths (via mouse click and drag)
- full R5+ testing and compliance (I developed with R6 and I currently use R7)
- full cross-browser testing and compliance (I developed with IE6, I currently use IE7, and I've only briefly tested with Firefox 2)
- using the search function on views with response hierarchies doesn't work quite right at the moment
- a proper scrollbar type navigation instead of the simple scroll up/down and page up/down arrows
Posted by Patrick Kwintensson on 05/16/2007 04:28:47 AMThanks for the update
Hej Thomas,
thanks for the update. It works and looks reallt nice. Great job!
Posted by Zafar A Shaikh on 07/08/2008 06:41:35 AMHow to remove the scrollbar
Hi Thomas,
This is a great script, really great to run on web-browsers.Thanks for sharing
I am using this code for my nsf. Due to our project requirement i need to remove the scroll bar from the views displayed using your code. when i removed it it was showing some blank space in place of scrollbar. some how i removed that space, but it had removed only from IE it has no effect on firefox or safari. Can you suggest me a way to remove that scrollbar.
 Add your comment!