<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ExtJS 框架学习演示 - 数据表格应用</title>
<link rel="stylesheet" type="text/css" href="https://cdn.bootcdn.net/ajax/libs/extjs/6.2.0/classic/theme-triton/resources/theme-triton-all.css">
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/extjs/6.2.0/ext-all.js"></script>
<style>
body {
margin: 0;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #2c3e50, #34495e);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
margin: 0;
font-size: 2.5em;
font-weight: 300;
}
.header p {
margin: 10px 0 0;
opacity: 0.9;
font-size: 1.1em;
}
.content {
padding: 30px;
}
.info-card {
background: #f8f9fa;
border-left: 4px solid #3498db;
padding: 20px;
margin-bottom: 30px;
border-radius: 8px;
}
.info-card h3 {
color: #2c3e50;
margin-top: 0;
}
.demo-section {
margin-top: 40px;
}
.demo-title {
font-size: 1.5em;
color: #2c3e50;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #ecf0f1;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🚀 ExtJS 框架学习演示</h1>
<p>基于 CSDN 博客《前端框架Ext学习之框架搭建》的完整实现</p>
</div>
<div class="content">
<div class="info-card">
<h3>📚 ExtJS 框架介绍</h3>
<p><strong>ExtJS</strong> 是一个强大的 JavaScript 类库,基于面向对象编程(OOP),具有出色的扩展性。它提供了丰富的、非常漂亮的外观体验,核心组件覆盖了构建富客户端常用的组件。</p>
<p><strong>核心优势:</strong> 与后台技术无关的前端 Ajax 框架,可用于 .Net、Java、Php 等各种开发语言。</p>
</div>
<div class="info-card">
<h3>🔧 技术要点</h3>
<ul>
<li><strong>核心文件:</strong> ext-all.css, ext-base.js, ext-all.js</li>
<li><strong>编程思想:</strong> 面向对象编程 (OOP)</li>
<li><strong>主要模块:</strong> data, widget, form, grid, dd, menu</li>
<li><strong>最强组件:</strong> Grid(数据表格)</li>
</ul>
</div>
<div class="demo-section">
<div class="demo-title">🎯 ExtJS 数据表格演示</div>
<div id="extjs-demo"></div>
</div>
</div>
</div>
<script type="text/javascript">
Ext.onReady(function() {
// 创建数据存储
var store = Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
fields: ['name', 'email', 'phone'],
data: {
'items': [
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244" },
{ 'name': 'Marge', "email": "marge@simpsons.com", "phone": "555-222-1254" }
]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
// 创建表格面板
var grid = Ext.create('Ext.grid.Panel', {
title: '辛普森一家 - 联系人信息',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{
header: '姓名',
dataIndex: 'name',
width: 120,
align: 'center'
},
{
header: '邮箱',
dataIndex: 'email',
flex: 1,
renderer: function(value) {
return Ext.String.format('<a href="mailto:{0}" style="color: #3498db; text-decoration: none;">{1}</a>', value, value);
}
},
{
header: '电话',
dataIndex: 'phone',
width: 150,
align: 'center',
renderer: function(value) {
return Ext.String.format('<span style="color: #27ae60; font-weight: 500;">{0}</span>', value);
}
}
],
height: 300,
width: '100%',
renderTo: 'extjs-demo',
viewConfig: {
stripeRows: true,
enableTextSelection: true
},
bbar: {
xtype: 'pagingtoolbar',
store: store,
displayInfo: true,
displayMsg: '显示第 {0} - {1} 条,共 {2} 条',
emptyMsg: "没有数据"
}
});
// 添加一些交互功能
grid.on('itemclick', function(view, record, item, index, e) {
Ext.Msg.alert('联系人信息',
'姓名: ' + record.get('name') + '<br>' +
'邮箱: ' + record.get('email') + '<br>' +
'电话: ' + record.get('phone')
);
});
});
</script>
</body>
</html>