开发者

jqgrid not loaded in ui kindly help me [closed]

开发者 https://www.devze.com 2023-03-04 16:08 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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开发者_如何学Python 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>


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消