extjs_03_grid(添加数据)

extjs_03_grid(添加数据)

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

extjs_03_grid(添加数据)

extjs_03_grid(添加数据)

extjs_03_grid(添加数据)

<%@ 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>

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117265.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • MyEclipse(最新版[2018.9.0])激活成功教程

    MyEclipse(最新版[2018.9.0])激活成功教程如果需要创建web项目,可以用这个网站试一试,这个激活成功教程包有点问题,不能创建web项目。(忽略以下文章,节约时间)————————————————————————我是一条漂亮的分割线———————————————————免…

    2022年9月26日
    0
  • 语音芯片,语音合成芯片,嵌入式语音合成软件的区别

    语音芯片,语音合成芯片,嵌入式语音合成软件的区别在当前科技发达,越来越智能的时代,追求产品体验更好,人机交互带有语音播报越来越成为一种时尚。无论是家用产品,还是室外公共设备,市场上带有语音提示和语音预警的产品也与日俱增,越来越受到消费者的青睐,语音功能让产品更智能,极大的增强了用户的产品体验。除了手机,平板等智能设备外,在智能家居等产品上要实现语音播报功能,有以下3种解决方案,我们逐一进行介绍。

    2022年6月26日
    23
  • C++ int转char_c语言中int转char

    C++ int转char_c语言中int转char文章目录1.通过ascii码:2.直接转换(更简单,推荐)1.通过ascii码:chara=’0′;intia=(int)a;/*notethattheintcastisnotnecessary–intia=awouldsuffice*/cout<<ia<<endl;结果如下:可以看出这种方法得到的其实是ch…

    2022年10月2日
    1
  • IOSG Ventures宣布加入Celer状态守卫者网络以及cBridge流动性桥接网络

    IOSG Ventures宣布加入Celer状态守卫者网络以及cBridge流动性桥接网络IOSGVentures宣布加入Celer状态守卫者网络,并已建立Celer验证人节点。同时,IOSGVentures也宣布加入CelercBridge流动性桥接网络,为其提供流动性。IOSGVentures将与Celer共同维护其二层扩容网络的可用性和安全性,并为其生态发展提供持续可靠的基础设施服务。IOSGVentures现已成为Celer状态守卫者网络验证人节点IOSGVentures成立于2017年,是由社区驱动的研究型早期美元基金,在中国、美国和新…

    2022年6月4日
    31
  • db2top命令详解「建议收藏」

    db2top命令详解「建议收藏」目录1.db2top命令语法2.db2top运行模式2.1交互模式2.2批量模式3.db2top监控模式3.1数据库监控(d)3.2表空间监控(t)3.3动态SQL监控(D)3.4会话监控(l)3.5缓存池监控(b)3.6锁监控(U)3.7表监控(T)3.8瓶颈监控(B)4.其他1.db2top命令语法可使用命令行db2top–h查看,这里就不做赘述了。2.db2top运行模式db2t…

    2022年9月16日
    0
  • AJAX(Asynchronous JavaScript And XML)

    AJAX(Asynchronous JavaScript And XML)

    2021年7月7日
    70

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号