Extjs之Gridpanel

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Extjs5 GridPanel</title>
		<link rel="stylesheet" type="text/css" href="extjs/packages/ext-theme-classic/build/resources/ext-theme-classic-all-debug.css"/>
		<link rel="stylesheet" type="text/css" href="extjs/packages/icon.css"/>
		<script src="extjs/ext-all-debug.js" type="text/javascript" charset="utf-8"></script>
		<script src="extjs/packages/ext-locale/build/ext-locale-zh_CN-debug.js" type="text/javascript"></script>
		<script type="text/javascript">
			Ext.onReady(function(){
				
				// 定义数据模型
				Ext.define('User', {
				    extend: 'Ext.data.Model',
				    fields: [ 'name', 'email', 'age', 'phone' ]
				});
				
				// 创建数据仓库
				var store = Ext.create('Ext.data.Store', {
					model: 'User',
    				pageSize: 5,
					data: {
						items: [{
							name: 'Lisa',
							email: 'lisa@simpsons.com',
							age:23,
							phone: '555-111-1224'
						}, {
							name: 'Bart',
							email: 'bart@simpsons.com',
							age:23,
							phone: '555-222-1234'
						}, {
							name: 'Homer',
							email: 'homer@simpsons.com',
							age:23,
							phone: '555-222-1244'
						}, {
							name: 'Marge',
							email: 'marge@simpsons.com',
							age:23,
							phone: '555-222-1254'
						}, {
							name: 'Marge',
							email: 'marge@simpsons.com',
							age:23,
							phone: '555-222-1254'
						}]
					},
					proxy: {
						type: 'memory',
						reader: {
							type: 'json',
							rootProperty: 'items'
						}
					}
				});
				
				// The data store containing the list of states
				var states = Ext.create('Ext.data.Store', {
				    fields: ['abbr', 'name'],
				    data : [
				        {"abbr":"AL", "name":"姓名"},
				        {"abbr":"AK", "name":"邮箱"},
				        {"abbr":"AZ", "name":"手机"}
				        //...
				    ]
				});
				
				// Create the combo box, attached to the states data store
				var combo = Ext.create('Ext.form.ComboBox', {
				    store: states,
				    width:60,
				    queryMode: 'local',
				    displayField: 'name',
				    valueField: 'abbr',
				    allowBlank:false,
				    value:'AL'
				});
				
				// 创建数据表格
				var grid = Ext.create('Ext.grid.Panel', {
					// xtype: 'gridpanel', // 指定创建gridpanel
					title: '管理员列表',
					region:'center',
					iconCls:'icon-Group',
					selType: "checkboxmodel", // 显示复选框
					selModel: {
					    injectCheckbox: 1,
					    mode: "SIMPLE",     //"SINGLE"/"SIMPLE"/"MULTI"
					    checkOnly: true     //只能通过checkbox选择
					},
					collapsible:true,
					columnLines:true,
					columns: [{ // 显示行号
						xtype: "rownumberer",
						text: ''
					},{
						text: '姓名',
						dataIndex: 'name'
					}, {
						text: '邮箱',
						dataIndex: 'email',
						flex: 1
					},{
						text: '年龄',
						dataIndex: 'age'
					}, {
						text: '手机',
						dataIndex: 'phone'
					}],
					store: store,
					// 创建工具栏
					tbar:[{
						xtype:'button',
						iconCls:'icon-Add',
						text:'添加',
						listeners:{
							click:function(){
								alert('Add');
							}
						}
					}, {
						xtype:'button',
						iconCls:'icon-Bulletedit',
						text:'修改'
					}, '-' ,{
						xtype:'button',
						iconCls:'icon-Delete',
						text:'删除'
					}, {
						xtype:'button',
						iconCls:'icon-Delete',
						text:'批量删除'
					}, '-', {
						xtype:'button',
						iconCls:'icon-Pageexcel',
						text:'导出'
					}, '->', combo, {
						xtype:'textfield'
					}, {
						xtype:'button',
						plain: true,
						text:'检索',
						iconCls:'icon-Bulletmagnify'
					}, {
						xtype:'button',
						plain: true,
						text:'高级检索',
						iconCls:'icon-Bulletmagnify'
					}],
					bbar: { xtype: "pagingtoolbar", store: store, displayInfo: true }
				});
				
				// 创建应用
				Ext.create('Ext.panel.Panel', {
					plugins: 'viewport', // 自适应浏览器窗口
					layout: 'fit',
					border: false,
					items: {
						xtype: 'panel',
						layout: 'border',
						border: false,
						items: [grid]
					}
				});
			});
		</script>
	</head>
	<body>
	</body>
</html>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值