Lesson 6: Create a Dojo data grid
In this lesson, you continue to create the web client interface.
You add a Dojo data grid widget to the page and populate the grid
with content.
About this task
Procedure
Results
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="dojo/dijit/themes/dijit.css">
<link rel="stylesheet" type="text/css"
href="dojo/dijit/themes/claro/claro.css">
<title>ShowMovies</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript"
data-dojo-config="isDebug: false, async: true, parseOnLoad: true"
src="dojo/dojo/dojo.js"></script>
<script type="text/javascript">
require(
// Set of module identifiers
[ "dojo", "dojo/parser", "dijit/layout/BorderContainer",
"dijit/layout/ContentPane", "dojox/grid/DataGrid",
"dojo/data/ItemFileReadStore" ],
// Callback function, invoked on dependencies evaluation results
function(dojo) {
dojo.ready(function() {
dojo.xhrGet({
url : "MovieList.json",
handleAs : "json",
load : function(response, ioArgs) {
var newData = {
identifier : "title",
items : response.result
};
var dataStore = new dojo.data.ItemFileReadStore({
data : newData,
id : "dataStoreId"
});
var grid = dijit.byId("gridId");
grid.setStore(dataStore);
},
error : function(response, ioArgs) {
}
});
});
});
</script>
<link rel="stylesheet" type="text/css" title="Style"
href="dojo/dojox/grid/resources/Grid.css">
<link rel="stylesheet" type="text/css" title="Style"
href="dojo/dojox/grid/resources/claroGrid.css">
</head>
<body class="claro">
<div id="BorderContainer" style="height: 100%; width: 100%"
data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline'">
<div data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'top'" style="text-align: center">My Movie Web Application!</div>
<div data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'">
<table id="gridId" autowidth="true"
data-dojo-type="dojox.grid.DataGrid"
data-dojo-props="rowSelector:'20px'">
<thead>
<tr>
<th field="title">Title</th>
<th field="director">Director</th>
<th field="actor">Actor</th>
<th field="description">Description</th>
</tr>
</thead>
</table>
</div>
<div data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'right'"></div>
</div>
</body>
</html>
Lesson checkpoint
You created the web page code for the Dojo client.
You learned:
- How to add a data grid to a web page.
- How to use content assist to rapidly write Dojo code



