jqgrid 未加载到 ui 中,请帮助我

发布于 2024-11-06 03:36:08 字数 3589 浏览 0 评论 0原文

你好,我第一次使用 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪异←思 2024-11-13 03:36:08

如何此处查看您发布的 XML 数据jqGrid。我在第一行只插入了两个空格。我希望这是剪切和粘贴错误。

此外,我将 type="text/css" 属性插入到

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 additionally height:'auto'. The parameters datatype: 'xml' and mtype: 'GET' can be also removed, because the values are default (see the documentation).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文