<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>My JSP "index.jsp" starting page</title> <link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css">
<script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script>
<script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script> <script type="text/javascript">
Ext.onReady(function() {
// 自己定义数据模型
var myModel = Ext.define("studentInfo", {
extend : "Ext.data.Model",
fields : [ {
type : "string",
name : "stuNo"
}, {
type : "string",
name : "stuName"
}, {
type : "string",
name : "stuClass"
}, {
type : "number",
name : "chScore"
}, {
type : "number",
name : "maScore"
}, {
type : "number",
name : "enScore"
} ]
});
// 本地数据
var myData = [ [ "No1", "wangzs1", "1年级", 80, 67, 49 ], [ "No2", "wangzs2", "2年级", 65, 57, 79 ],
[ "No3", "wangzs3", "3年级", 45, 77, 59 ], [ "No4", "wangzs4", "4年级", 99, 27, 19 ],
[ "No5", "wangzs5", "5年级", 23, 97, 99 ], [ "No6", "wangzs6", "6年级", 34, 67, 99 ] ];
// 数据存储
var myStore = Ext.create("Ext.data.Store", {
model : "studentInfo",
data : myData
}); // 表格
var myGrid = new Ext.grid.Panel({
columns : [ {
xtype : "rownumberer",
text : "行号"
}, {
text : "学号",
dataIndex : "stuNo"
}, {
text : "姓名",
dataIndex : "stuName"
}, {
text : "班级",
dataIndex : "stuClass"
}, {
text : "语文",
dataIndex : "chScore"
}, {
text : "数学",
dataIndex : "maScore"
}, {
text : "英语",
dataIndex : "enScore"
} ],
store : myStore
}); // 新增panel
var addPanel = Ext.create("Ext.form.Panel", {
items : [ {
xtype : "textfield",
fieldLabel : "学号",
name : "stuNo"
}, {
xtype : "textfield",
fieldLabel : "姓名",
name : "stuName"
}, {
xtype : "textfield",
fieldLabel : "班级",
name : "stuClass"
}, {
xtype : "numberfield",
fieldLabel : "语文",
name : "chScore"
}, {
xtype : "numberfield",
fieldLabel : "数学",
name : "maScore"
}, {
xtype : "numberfield",
fieldLabel : "英语",
name : "enScore"
} ]
}); // 新增窗体
var addWindow = Ext.create("Ext.window.Window", {
title : "新增学生成绩",
closeAction : "hide",//设置该属性新增窗体关闭的时候是隐藏
width : 300,
height : 300,
items : addPanel,
layout : "fit",
bbar : {
xtype : "toolbar",
items : [
{
xtype : "button",
text : "保存",
listeners : {
"click" : function(btn) {
var form = addPanel.getForm();
var stuNo = form.findField("stuNo").getValue();
var stuName = form.findField("stuName").getValue();
var stuClass = form.findField("stuClass").getValue();
var chScore = form.findField("chScore").getValue();
var maScore = form.findField("maScore").getValue();
var enScore = form.findField("enScore").getValue();
Ext.Msg.alert("新增的数据", "{" + stuNo + ":" + stuName + ":" + stuClass + ":" + chScore + ":"
+ maScore + ":" + enScore + "}");
}
}
}, {
xtype : "button",
text : "取消",
listeners : {
"click" : function(btn) {
btn.ownerCt.ownerCt.close();
}
}
} ]
}
}); // 窗体
var window = Ext.create("Ext.window.Window", {
title : "学生成绩表",
width : 600,
height : 400,
items : myGrid,
layout : "fit",
tbar : {
xtype : "toolbar",
items : {
xtype : "button",
text : "新增",
listeners : {
"click" : function(btn) {
addPanel.getForm().reset();//新增前清空表格内容
addWindow.show();
}
}
}
}
});
window.show();
});
</script> </head> <body>
显示表格
<br>
</body>
</html>

版权声明:本文博客原创文章。博客,未经同意,不得转载。

extjs_03_grid(添加数据)的更多相关文章

  1. C#向sql server数据表添加数据源代码

    HoverTree解决方案 学习C#.NET,Sql Server,WinForm等的解决方案. 本文链接http://hovertree.com/h/bjaf/0jteg8cv.htm 使用的技术. ...

  2. js表单动态添加数据并提交

    情景1:已经存在form对象了,动态为form增加对象并提交 function formAppendSubmit(){ var myform=$('#newArticleForm'); //得到for ...

  3. 从零开始,搭建博客系统MVC5+EF6搭建框架(2),测试添加数据、集成Autofac依赖注入

    一.测试仓储层.业务层是否能实现对数据库表的操作 1.创建IsysUserInfoRepository接口来继承IBaseRepository父接口 namespace Wchl.WMBlog.IRe ...

  4. 使用C#类向数据库添加数据的例子源码

    在上一篇中,增加了sql server数据库操作类SqlOperator,用于操作sql server数据库.还有一个SqlStringHelper类,用于处理sql语句的单引号.那么这两个类怎么使用 ...

  5. EF批量添加数据性能慢的问题的解决方案

    //EF批量添加数据性能慢的问题的解决方案 public ActionResult BatchAdd() { using (var db = new ToneRoad.CEA.DbContext.Db ...

  6. mybatis+oracle添加一条数据并返回所添加数据的主键问题

    最近做mybatis+oracle项目的时候解决添加一条数据并返回所添加数据的主键问题 controller层 @RequestMapping("/addplan") public ...

  7. Android 数据库管理— — —添加数据

    <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" ...

  8. Java使用Mysql数据库实现批量添加数据

    EmployeeDao.java //批处理添加数据 public int saveEmploeeBatch(){ int row = 0; try{ con = DBCon.getConn(); S ...

  9. Eclipse中java向数据库中添加数据,更新数据,删除数据

    前面详细写过如何连接数据库的具体操作,下面介绍向数据库中添加数据. 注意事项:如果参考下面代码,需要 改包名,数据库名,数据库账号,密码,和数据表(数据表里面的信息) package com.ning ...

随机推荐

  1. [置顶] Codeforces Round #197 (Div. 2)(完全)

    http://codeforces.com/contest/339/ 这场正是水题大放送,在家晚上限制,赛后做了虚拟比赛 A,B 乱搞水题 C 我是贪心过的,枚举一下第一个拿的,然后选使差值最小的那个 ...

  2. C语言获取文件SHA1哈希

    安全散列算法(Secure Hash Algorithm)主要适用于数字签名标准 (Digital Signature Standard DSS)它定义了数字签名算法(Digital Signatur ...

  3. 初识google多语言通信框架gRPC系列(四)C++中使用gRPC

    我的这几篇文章都是使用gRPC的example,不是直接编译example,而是新建一个项目,从添加依赖,编译example代码,执行example.这样做可以为我们创建自己的项目提供借鉴.如果对gR ...

  4. codeforces #256 A. Rewards

    A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  5. swift排序算法和数据结构

    var arrayNumber: [Int] = [2, 4, 6, 7, 3, 8, 1] //冒泡排序 func maopao(var array: [Int]) -> [Int] { fo ...

  6. WebService什么?

    一.前言 我们或多或少都听过WebService(Web服务),有一段时间非常多计算机期刊.书籍和站点都大肆的提及和宣传WebService技术.当中不乏非常多吹嘘和做广告的成分.可是不得不承认的是W ...

  7. WPF 绑定

    WPF里分三种Binding:Binding, PriorityBinding, MultiBinding,这三种Binding的基类都是BindingBase,而BindingBase又继承于Mar ...

  8. 20那天android得知

    20多天的实习(事实上,一个人学习的东西)要结束, 剩下的只是读研. 这项20许多天我学到了很多东西, 对android的发展也有了一定的了解.之后写这篇文章主要完成的研究可以得知快速回升 1.安德鲁 ...

  9. UI —— 计算器

    #import <UIKit/UIKit.h> @interface MyViewController :UIViewController { NSInteger _firstName; ...

  10. html学习笔记二

    html图片标记 <html> <head> <title>图片演示</title> </head> ----------------图片演 ...