PDA

View Full Version : rowclick listener not getting invoked for custom grid



shafi_363
14 Jul 2009, 3:34 AM
Hi,

I am using custom grid component which is extended from EditorGridPanel. I also had the rowclick listener embedded in the custom grid. But for some reason it is not getting invoked.

Could someone let me know whether am I missing something.

Here is my code.


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript">

Ext.ns('Example');
Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';

Example.Grid = Ext.extend(Ext.grid.EditorGridPanel, {
initComponent:function() {
Ext.apply(this, {
store : new Ext.data.Store({
data: [
[1,"84m.jpg","Office Space","Mike Judge","1999-02-19",1,"Work Sucks",19.95,true],
[3,"42m.jpg","Super Troopers","Jay Chandrasekhar","2002-02-15",1,"Altered State Police",14.95,1],
[4,"12m.jpg","American Beauty","Sam Mendes","1999-10-01",2,"... Look Closer",19.95,true],
[5,"49m.jpg","The Big Lebowski","Joel Coen","1998-03-06",1,"The \"Dude\"",21.9,'true'],
[6,"94m.jpg","Fight Club","David Fincher","1999-10-15",3,"How much can you know about yourself...",19.95,true]
],
reader: new Ext.data.ArrayReader({id:'id'}, Ext.data.Record.create([
'id',
'coverthumb',
'title',
'director',
{name: 'released', type: 'date', dateFormat: 'Y-m-d'},
'genre',
'tagline',
{name: 'price', type: 'float'},
{name: 'available', type: 'bool'}
]))
})
,columns: [
{header: "Title", dataIndex: 'title'},
{header: "Director", dataIndex: 'director'},
{header: "Released", dataIndex: 'released', renderer: Ext.util.Format.dateRenderer('m/d/Y')},
{header: "Genre", dataIndex: 'genre'},
{header: "Tagline", dataIndex: 'tagline'}
]
,viewConfig:{forceFit:true}
,listeners: {
rowclick: function(grid, rowIndex, e) {
alert("coming");
}

}
,sm: new Ext.grid.RowSelectionModel({
singleSelect: true
})
});

Example.Grid.superclass.initComponent.apply(this, arguments);
}
});

Ext.reg('examplegrid', Example.Grid);

// application entry point
Ext.onReady(function() {
Ext.QuickTips.init();

var win = new Ext.Window({
renderTo: Ext.getBody()
,width:600
,height:450
,plain:true
,layout:'fit'
,border:false
,closable:false
,items:[{
xtype:'tabpanel'
,defaults:{layout:'fit'}
,id:'tabpanel'
,activeItem:0
,items: [{
title:'Grid Tab'
,id:'gridtab'
,xtype:'examplegrid'
,autoScroll:true
},{
title:'Text Tab'
,id:'firsttab'
,bodyStyle:'padding:10px'
,html:'Click on Grid Tab to instantiate and render the grid.'
}]
}]
});
win.show();
});
</script>
<title id="page-title"></title>
</head>

<body></body>
</html>

Animal
14 Jul 2009, 3:36 AM
You can't add listeners like that.

Use addListener