Ext Js 3.2中关于PropertyGrid即属性表格的使用

1:代码


<%@ 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>gridPanel</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="ext3.2/resources/css/ext-all.css"></link>
	<script type="text/javascript" src="ext3.2/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="ext3.2/ext-all.js"></script>
	<script type="text/javascript" src="ext3.2/src/local/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript">
	  Ext.onReady(function() {   
		var grid = new Ext.grid.PropertyGrid({
			  title: '员工属性表格',
			  width: 300,
			  height: 200,
			  frame: true,
			  source: {
			       "员工名称": '张三',
			       "出生日期": new Date(1978, 01, 02),
			       "性别": '男',
			       "是否已婚": true,
			       "年龄": 31
			  }
      });
         grid.render('cumGrid');
	});
	</script>
  </head>
  
  <body>
    <div id="cumGrid"> </div>
  </body>
</html>

2:程序效果图

 

   PropertyGrid模仿了典型开发环境中的属性表工具,属性表的每一行表现对象的一个属性,属性的值以"名称、值"对的形式保存在Ext.grid.PropertyRecord中。

   注意frame属性,它的值为true,表示面板的边框外框可自定义的,若为false,表示边框为1px的点线(默认值为false),source表示要显示的数据对象

  当frame的属性值为false时,效果图如下:

 

主要是注意表框的差别


3:只读的PropertyGrid

    PropertyGrid用来显示一些属性信息,有很多时候数据是不允许随意改动的,但是PropertyGrid默认提供了可编辑功能,而且也没有提供可以配置是否允许编辑

的功能属性,这样使有些数据的安全性丧失了

    实际上只要在beforeedit事件处理中设置e.cancel=true就可以了,代码如下:

 

 Ext.onReady(function() {   
		var grid = new Ext.grid.PropertyGrid({
			  title: '员工属性表格',
			  width: 300,
			  height: 200,
			  frame: true,
			  source: {
			       "员工名称": '张三',
			       "出生日期": new Date(1978, 01, 02),
			       "性别": '男',
			       "是否已婚": true,
			       "年龄": 31
			  }
      });
         grid.render('cumGrid');
         grid.on('beforeedit', function(e){
        	 e.cancel = true;
        	 return false;
         });
         
	});


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我可以为您讲解一下使用 Ext Grid 控件。 Grid 是一个非常常用的控件,它可以展示表格数据。在使用 Grid 之前,我们需要先引入 ExtGrid 组件,可以通过以下代码进行引入: ```javascript Ext.require(['Ext.grid.*']); ``` 接着,我们可以定义一个 Ext.grid.Panel 对象,即一个 Grid 面板。以下是一个简单的 Grid 面板的定义示例: ```javascript Ext.create('Ext.grid.Panel', { title: 'My Grid Panel', store: myStore, columns: [ { text: 'Name', dataIndex: 'name' }, { text: 'Email', dataIndex: 'email', flex: 1 }, { text: 'Phone', dataIndex: 'phone' } ], height: 200, width: 400, renderTo: Ext.getBody() }); ``` 在上述代码,我们定义了一个 Grid 面板,它包含了一个标题、一个数据源(即 store)、三列数据(name、email 和 phone)以及一个高度和宽度。在最后,我们将这个 Grid 面板渲染到页面。 其,store 是 Grid 的数据源,我们需要先定义一个 store 对象。以下是一个简单的 store 对象的定义示例: ```javascript var myStore = Ext.create('Ext.data.Store', { fields: ['name', 'email', 'phone'], data: [ { name: 'Lisa', email: '[email protected]', phone: '555-111-1224' }, { name: 'Bart', email: '[email protected]', phone: '555-222-1234' }, { name: 'Homer', email: '[email protected]', phone: '555-222-1244' }, { name: 'Marge', email: '[email protected]', phone: '555-222-1254' } ] }); ``` 在上述代码,我们定义了一个包含 name、email 和 phone 三个字段的数据源。我们通过 data 属性来设置数据,可以看到,我们在这里直接将数据写在代码。在实际,我们通常是从后台获取数据,然后将数据赋值给 store 对象。 以上就是使用 Ext Grid 控件的基本步骤。希望能对您有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

波哥的技术积累

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值