可编辑表格:Ext.grid.EditorGridPanel

1、Ext.grid.EditorGridPanel
      主要配置项:

            clicksToEdit:设置点击单元格进入编辑模式的点击次数,默认为2
            autoEncode:是否自动编码/解码HTML内容,默认为false
            selModel:默认为Ext.grid.CellSelectionModel
  
      主要方法:
            startEditing( Number rowIndex, Number colIndex ):开始编辑指定单元格
            stopEditing( [Boolean cancel] ):结束编辑操作

 

 

2、范例源码

var datas = [[1,"张三",24,"男",new Date(1986,06,09)], [2,"李四",30,"女",new Date(1980,09,13)], [3,"王五",28,"男",new Date(1982,01,10)]];
  			
var person = Ext.data.Record.create([
	{name: "personId", mapping: 0},
	{name: "personName", mapping: 1},
	{name: "personAge", mapping: 2},
	{name: "personGender", mapping: 3},
	{name: "personBirth", mapping: 4}
]);

//复选框选择模式
var checkboxSM = new Ext.grid.CheckboxSelectionModel({
	checkOnly: false,
	singleSelect: false
});

var cellSM = new Ext.grid.CellSelectionModel();

var grid = new Ext.grid.EditorGridPanel({
	title: "EditorGridPanel实例",
	renderTo: "div1",
	width: 500,
	height: 300,
	frame: true,
	tbar: [
		{
			text: "保存",
			iconCls: "save",
			handler: function(){
				
			}
		},
		{
			text: "刷新",
			iconCls: "refresh",
			handler: function(){
				
			}
		}
	],
	store: new Ext.data.Store({
		reader: new Ext.data.ArrayReader({id:0}, person),
		data: datas
	}),
	columns: [
		checkboxSM,
		{
			id:"personId", 
			header:"编号", 
			width:50, 
			dataIndex:"personId"
		},
		{
			id:"personName", 
			header:"姓名", 
			width:70, 
			dataIndex:"personName", 
			editor:new Ext.form.TextField({
				allowBlank:false
			})
		},
		{
			id:"personAge", 
			header:"年龄", 
			width:45, 
			dataIndex:"personAge", 
			editor:new Ext.form.NumberField()
		},
		{
			id:"personGender", 
			header:"性别", 
			width:45, 
			dataIndex:"personGender", 
			editor: new Ext.form.ComboBox({
				editable: false,
				displayField: "sex",
				mode: "local",
				triggerAction: "all",
				store: new Ext.data.SimpleStore({
					fields: ["sex"],
					data: [["男"], ["女"]]
				})
			})
		},
		{
			id:"personBirth", 
			header:"出生日期", 
			width:120, 
			dataIndex:"personBirth", 
			renderer:Ext.util.Format.dateRenderer("Y年m月d日"), 
			editor:new Ext.form.DateField({
				format: "Y-m-d"
			})
		}
	],
	autoExpandColumn: "personBirth",
	stripeRows: true,
	sm: checkboxSM
});

  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值