其他人已经解释了为什么它不工作...您的处理器期望的记录是一个全局变量,处理程序被调用,不知道从哪里得到记录。
你真正应该做的是设置一个监听你的数据模型的一个'headerclick就像
// EXT 4 version: wrap with Ext.onReady
Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
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" }
]
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
colModel: {
listeners: {
headerclick: function(container, column, e, target, options) {
if (column.id == 'col-name') {
alert('Anything you want');
}
}
},
items: [
{ header: 'Name', dataIndex: 'name', id: 'col-name', sortable: false},
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
]},
height: 200,
width: 400,
renderTo: Ext.getBody()
});
你提到你使用分机3,headerclick略有不同,它应该是设置在网格本身上,而不是在标题容器(列模型)中。喜欢的东西
var records = Ext.data.Record.create([{name: 'msgId', type:'string', mapping: 'msgId'},]);
...
...
var detailGrid = new Ext.grid.GridPanel({
listeners: {
headerclick: function(grid, index, e) {
if (index == 1) {
alert('Clicked Grid');
}
}
},
id:'detailGrid',
store: dataStore,
cm: new Ext.grid.ColumnModel({
columns: [
{id:'msgId',hidden: true, dataIndex: 'msgId'},
{header: 'info',xtype: 'templatecolumn',tpl: '<a href="#">View Message Details</a>'}
]
}),
不知道,但你可能要在创建“记录”提醒其价值之一,以确保该对象已正确创建而不是默默地失败后,在1号线 – goatslacker
权的末尾删除逗号一些原因。 –
好的......在逗号后面有一些东西..我编辑了我的文章 – Victor