開發環境:
IDE:MyEclipse6.6GA
Web Server:Tomcat 6.0.20
Database:MySql 5.1.36
MVC:Struts2.1.8
FrameWork:Spring2.0,Hibernate3.2
Client UI:Ext2.3.0
一、grid頁面(grid0.jsp):
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'combox.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="css/onReady.css">
<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" src="extjs/ext-lang-zh_TW.js"></script>
<script type="text/javascript">
<!--
Ext.onReady(function(){
var store = new Ext.data.Store({
data: [
[1,
"Office Space",
"Mike Judge",
"1999-02-19",
1,
"Work Sucks",
"19.95",
1,
"OfficeSpace"],
[3,
"Super Troopers",
"Jay Chandrasekhar",
"2002-02-15",
0,
"Altered State Police",
"14.95",
1,
"SuperTroopers"]
//...more rows of data removed for readability...//
],
reader: new Ext.data.ArrayReader({id:'id'}, [
'id',
'title',
'director',
{name: 'released', type: 'date', dateFormat: 'Y-m-d'},
{name:'genre',type:'boolean'},
'tagline',
'price',
'available',
'cover'])
});
//Combining two columns function
function title_tagline(val, x, store){
return '<b>'+val+'</b><br>'+store.data.tagline;
}
//Generating HTML and graphics
function cover_image(val){
return '<img src="images/'+val+'.jpg" width="50%" height="50%">';
}
// add your data store here
var grid = new Ext.grid.GridPanel({
//renderTo: document.body,
renderTo:'example-grid',
frame:true,
title: 'Movie Database',
height:200,
width:550,
stripeRows:true,
store: store,
//Defining a Grids column model and want to display column
columns: [
{header: "Cover", dataIndex: 'cover',renderer:cover_image},
//Combining two columns
{header: "Title", dataIndex: 'title',renderer:title_tagline},
{header: "Director", dataIndex: 'director'},
//Client-side sorting
{header: "Released", dataIndex: 'released',sortable:true,
renderer: Ext.util.Format.dateRenderer('m/d/Y')},
{header: "Genre", dataIndex: 'genre'},
{header: "Price",dataIndex: 'price'},
//setup hidden column
{header: "Tagline", dataIndex: 'tagline',hidden:true}
]
});
});
//-->
</script>
</head>
<body><br>
<center>
<h3><font color="red">Movie Database Grid</font></h3><br>
</center>
<table align="center" border="0">
<tr>
<td>
<div id="example-grid"></div>
<td>
</tr>
</table>
</body>
</html>
二、測試結果:
1.http://localhost:8080/ExtStudy/Basic/grid0.jsp
沒有留言:
張貼留言