我有这个 JSP 页面。当我运行它时,我没有收到任何错误。但也不要使用数据网格获取数据。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="MyPackage.PopulateTextbox" %>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
@import "http://localhost:8080/2_8_2012/js/dojo/resources/dojo.css";
@import "http://localhost:8080/2_8_2012/js/dijit/themes/nihilo/nihilo.css";
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" djConfig="isDebug: false, parseOnLoad: true"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.data.ItemFileWriteStore");
</script>
<%
String temp1;
PopulateTextbox obj = new PopulateTextbox();
temp1 = obj.method();
request.setAttribute("variable", temp1);
%>
<script type="text/javascript">
dojo.ready(function(){
var myVar = <%= request.getAttribute("variable") %>
var storedata={
identifier:"table1",
label:"name",
items: myVar
};
var store = new dojo.data.ItemFileReadStore({data: storedata});
var gridStructure =[[
{ field: "ID",
name: "ID_Emp",
width: "40%"
},
{
field: "Names",
name: "Name",
width: "40%"
}
]
];
var grid = new dojox.grid.DataGrid({
id: 'grid',
store: store,
structure: gridStructure,
});
//document.createElement('div'));
/*append the new grid to the div*/
//dojo.byId("gridDiv").appendChild(grid.domNode);
/*Call startup() to render the grid*/
grid.startup();
});
</script>
<title>Dojo Data</title>
</head>
<body>
<div jsid="grid" id="mygrid" dojoType="dojox.grid.DataGrid" title="Simple Grid" style="width: 500px; height: 150px;">
</div>
</body>
</html>
当我运行此页面时。并转到查看源我得到以下内容::
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
@import "http://localhost:8080/2_8_2012/js/dojo/resources/dojo.css";
@import "http://localhost:8080/2_8_2012/js/dijit/themes/nihilo/nihilo.css";
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" djConfig="isDebug: false, parseOnLoad: true"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<script type="text/javascript">
var myVar = [{"ID":1,"Names":"Shantanu"},{"ID":2,"Names":"Mayur"},{"ID":3,"Names":"Rohit"},{"ID":4,"Names":"Jasdeep"},{"ID":5,"Names":"Rakesh"}];
var storedata={
identifier:"table1",
label:"name",
items: myvar
};
var gridStructure =[{
cells:[
[
{ field: "ID",
name: "ID_Emp",
width: "40%", styles: 'text-align: right;'
},
{
field: "Names",
name: "Name",
width: "40%", styles: 'text-align: right;'
}
]
]
}];
</script>
<title>Dojo Data</title>
</head>
<body class=nihilo>
<div style="width: 400px; height: 300px;">
<div data-dojo-type="dojo.data.ItemFileReadStore" data-dojo-id="countryStoreForGrid" data-dojo-props="data:storedata"></div>
<div id="grid"
data-dojo-type="dojox.grid.DataGrid"
data-dojo-props="store:countryStoreForGrid,
structure:'gridStructure',
rowsPerPage:40">
</div>
</div>
</body>
</html>
我在 myVar 中有数据(用于 JSP 页面中的项目),如查看源页面中所示。但是屏幕上仍然没有显示任何内容。我的 HTML BODY 标记中是否有任何错误。? 请帮我解决一下这个。谢谢。