EXTJS7 grid 自定义单元格组件,并实现事件和属性绑定

小编:管理员 538阅读 2022.09.06

1. 创建gridrow.viewModel,controller2. 通过widgetcell.widget嵌套单元格内部组件
{
	xtype: 'grid',
	// gridrow对象配置
	itemConfig: {
		// 添加此项则会自动创建record字段并赋值
		viewModel: {text:'Verify'}
		// cell上定义的函数和事件绑定需在此处定义
		controller: {hBtn:function(){
			// 可通过vm取到record
			var record = this.getViewModel().get('record');
		}}
	},
	column:[{
		cell:{
			xtype: 'widgetcell',
			widget: {
				xtype: 'button',
				// 绑定到处理函数
				handler: 'hBtn',
				bind: {
					// 绑定到自定义vm字段
					text: '{text}',
					// 绑定到记录字段
                	tooltip: 'Verify {record.fullName}'
                }
			}
		}
	}]
}
复制
关联标签: