PDA

View Full Version : Grid itemdblclik event disable on specific column



fily55
13 Feb 2013, 4:40 AM
Hi guys,

I have a grid with the itemdblclick event. There is a certain column I want to disable this listener for. I.e. I don't want a row to do anything if I double click on a specific column.

Is this anyway possible?

I noticed the column has its own listeners but there isn't a dblitemclick listeners. I thought maybe I could overwrite the previous, but doesn't seem likely.

Thanks.

EDIT:
I also looked into the dblitemclick event and found that there is an index param. The problem is that this is for row. There doesn't seem to be a way to identify what column was clicked.

mitchellsimoens
14 Feb 2013, 9:20 PM
The index is the index of the record in the store. What you'd have to do is get what index the html element item is in the row.

sword-it
16 Feb 2013, 12:59 AM
Hi
As far as I understood your problem celldblclick must work correctly for you. Here is the sample example for you


Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ '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" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
listeners:{
celldblclick:function(grid, td, cellIndex, record, tr, rowIndex, e){
if(cellIndex!=2){ //for third column it wont do anything
alert('hello'); // do whatever you want to do here
}
}
},
renderTo: Ext.getBody()
});


Regards