jqgrid 未加载到 ui 中,请帮助我
你好,我第一次使用 jqgrid,但数据未加载到 UI
*html 文件:*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Grid</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-redmond/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<style>
html, body {
margin: 0;
padding: 0;
font-size: 75%;
}
</style>
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#list").jqGrid({
url:'/home/vbalamurugan/sename.jsp',
datatype: 'xml',
mtype: 'GET',
colNames:['PROPERTY_NAME','PROPERTY_VALUE'],
colModel :[
{name:'PROPERTY_NAME', index:'PROPERTY_NAME', width:300},
{name:'PROPERTY_VALUE', index:'PROPERTY_VALUE', width:300},
],
pager: '#pager',
rowNum:5,
rowList:[10,20,30],
sortname: '',
sortorder: 'desc',
viewrecords: true,
caption: 'Bala First Grid'
});
});
</script>
</head>
<body>
<table id="list"></table>
<div id="pager"></div></body>
</html
jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String jdbcURL = "jdbc:oracle:thin:@192.168.6.38:1521:XE";
Connection conn = null;
Statement stmt = null;
ResultSet rs =null;
String user ="raymedi_hq" ;
String passwd ="raymedi_hq";
int count=8;
StringBuffer sbf=new StringBuffer(250);
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn = DriverManager.getConnection(jdbcURL,user,passwd);
stmt = conn.createStatement();
response.setContentType("text/xml;charset=utf-8");
response.setHeader("", "Content-type: text/xml;charset=utf-8");
sbf.append("<?xml version='1.0' encoding='utf-8'?>");
sbf.append("<page>2</page>");
sbf.append("<total>3</total>");
sbf.append("<records>"+count+"</records>");
rs = stmt.executeQuery("SELECT PROPERTY_NAME,PROPERTY_VALUE FROM HQ_FA_TAG");
while(rs.next())
{
sbf.append("<cell><![CDATA["+rs.getString("PROPERTY_NAME")+"]]></cell>");
sbf.append("<cell><![CDATA["+rs.getString("PROPERTY_VALUE")+"]]></cell>");
}
sbf.append( "</row>");
sbf.append("</rows>");
out.println(sbf.toString);
System.out.println(sbf.toString());
rs.close();rs=null;
if (conn != null){
try{
conn.close();
}catch(Exception ex2){ex2.printStackTrace();}
}
}
catch(Exception e){e.printStackTrace();}
%>
</body>
</html>
Hello first time i used jqgrid but data not loaded in UI
*html file:*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Grid</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-redmond/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<style>
html, body {
margin: 0;
padding: 0;
font-size: 75%;
}
</style>
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#list").jqGrid({
url:'/home/vbalamurugan/sename.jsp',
datatype: 'xml',
mtype: 'GET',
colNames:['PROPERTY_NAME','PROPERTY_VALUE'],
colModel :[
{name:'PROPERTY_NAME', index:'PROPERTY_NAME', width:300},
{name:'PROPERTY_VALUE', index:'PROPERTY_VALUE', width:300},
],
pager: '#pager',
rowNum:5,
rowList:[10,20,30],
sortname: '',
sortorder: 'desc',
viewrecords: true,
caption: 'Bala First Grid'
});
});
</script>
</head>
<body>
<table id="list"></table>
<div id="pager"></div></body>
</html
jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String jdbcURL = "jdbc:oracle:thin:@192.168.6.38:1521:XE";
Connection conn = null;
Statement stmt = null;
ResultSet rs =null;
String user ="raymedi_hq" ;
String passwd ="raymedi_hq";
int count=8;
StringBuffer sbf=new StringBuffer(250);
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn = DriverManager.getConnection(jdbcURL,user,passwd);
stmt = conn.createStatement();
response.setContentType("text/xml;charset=utf-8");
response.setHeader("", "Content-type: text/xml;charset=utf-8");
sbf.append("<?xml version='1.0' encoding='utf-8'?>");
sbf.append("<page>2</page>");
sbf.append("<total>3</total>");
sbf.append("<records>"+count+"</records>");
rs = stmt.executeQuery("SELECT PROPERTY_NAME,PROPERTY_VALUE FROM HQ_FA_TAG");
while(rs.next())
{
sbf.append("<cell><![CDATA["+rs.getString("PROPERTY_NAME")+"]]></cell>");
sbf.append("<cell><![CDATA["+rs.getString("PROPERTY_VALUE")+"]]></cell>");
}
sbf.append( "</row>");
sbf.append("</rows>");
out.println(sbf.toString);
System.out.println(sbf.toString());
rs.close();rs=null;
if (conn != null){
try{
conn.close();
}catch(Exception ex2){ex2.printStackTrace();}
}
}
catch(Exception e){e.printStackTrace();}
%>
</body>
</html>
发布评论
评论(1)
如何此处查看您发布的 XML 数据jqGrid。我在第一行只插入了两个空格。我希望这是剪切和粘贴错误。
此外,我将
type="text/css"
属性插入到元素和
;
height:'auto'
。参数datatype: 'xml'
和mtype: 'GET'
也可以删除,因为这些值是默认值(请参阅 文档)。How you can see here the XML data which you posted can be read by jqGrid. I inserted only two blanks in the first line. I hope it was cut&paste errores.
Moreover I inserted
type="text/css"
attribzte to the<style>
element and<tr><td/></tr>
inside of<table>
element. After the changes the validator.w3.org find no problems more. I inserted additionallyheight:'auto'
. The parametersdatatype: 'xml'
andmtype: 'GET'
can be also removed, because the values are default (see the documentation).绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
关于作者
暂无简介
相关话题
热门标签
推荐作者
lorenzathorton8
文章 0 评论 0
Zero
文章 0 评论 0
萧瑟寒风
文章 0 评论 0
mylayout
文章 0 评论 0
tkewei
文章 0 评论 0
17818769742
文章 0 评论 0
友情链接
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。