Community articleDisplaying a GET request in a Dojo grid
Added by IBM contributorIBM on September 27, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Here is sample code to send a GET request to the Domino® Data Service and read the response via a Dojo object.
This particular request is a Database collection GET das901Create New Article. The code is in an HTML file intended for installation on a Domino server at data\domino\html.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
         "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Domino Rest Services - Application collections</title>
<style type="text/css">
    @import "/domjs/dojo-1.5.0/dijit/themes/tundra/tundra.css";
    @import "/domjs/dojo-1.5.0/dojo/resources/dojo.css";
    @import "/domjs/dojo-1.5.0/dojox/grid/resources/tundraGrid.css"; 
</style>
<script type="text/javascript" src="/domjs/dojo-1.5.0/dojo/dojo.js"  
    djConfig="parseOnLoad: true"></script>
<script>
    dojo.require("dojo.parser");
    dojo.require("dojo.data.ItemFileReadStore");
    dojo.require("dojox.data.JsonRestStore");
    dojo.require("dojox.grid.DataGrid");
 
var dasurl = "http://IBM-Z0SHI2LW4CZ.swg.usma.ibm.com/api/data";
var dasstore = new dojox.data.JsonRestStore({target: dasurl,idAttribute:"*replicaid"});
 
</script>
<style>
 
#grid { 
    border: 1px solid #333;
    width: 100%;
    height: 400px;
    font-size: 0.9em;
    font-family: Geneva, Arial, Helvetica, sans-serif;
    
}
 
</style>
 
</head>
<body class="tundra">
 
	<div style="width: 95%; height: 95%; padding: 25px" >
 
		<h1>Domino Rest Services - Application collections</h1>
 
		<table id="grid" dojoType="dojox.grid.DataGrid" store="dasstore" 
         		clientSort="true" width="auto">
        		<thead>
           			<tr>
				<th field="@title" width="auto" >Title</th> 
				<th field="@filepath" width="auto" >Filepath</th> 
				<th field="@replicaid" width="auto" >ReplicaID</th> 
				<th field="@template" width="auto" >Template</th> 
				<th field="@link" width="auto" >Link</th> 
           			</tr>
        		</thead>        
    		</table>
 
    </div>
 
</body>
</html>


Explanatory notes:
  • For this GET request, create a dojox.data.JsonRestStore object whose target is the resource URL, in this example http://IBM-Z0SHI2LW4CZ.swg.usma.ibm.com/api/data.
  • The dojox.grid.DataGrid table can then address response items from the REST store by name, for example, @title, @filepath, and so on.
  • For this example, if the name of the HTML file on the server is data\domino\html\dasdbreststore.html, the user addresses the file in a browser as:
  • http://ibm-z0shi2lw4cz.swg.usma.ibm.com/dasdbreststore.html
Parent topic: Programming Domino Data Service