PDA

View Full Version : Select row with right click



oturkan
2 May 2012, 8:40 AM
Hi

How can I select row with right click on grid panel

thanks

scottmartin
2 May 2012, 10:18 AM
See if this works:



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'change'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "change":100 },
{ 'name': 'Bart', "email":"bart@simpsons.com", "change":-20 },
{ 'name': 'Homer', "email":"home@simpsons.com", "change":23 },
{ 'name': 'Marge', "email":"marge@simpsons.com", "change":-11 }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Change', dataIndex: 'change', tdCls: 'x-change-cell' }
],
height: 200,
width: 400,
viewConfig: {
getRowClass: function(record, index) {
var c = record.get('change');
if (c < 0) {
return 'price-fall';
} else if (c > 0) {
return 'price-rise';
}
}
},
renderTo: Ext.getBody(),
viewConfig: {
stripeRows: true,

listeners: {
itemcontextmenu: function(view, rec, node, index, e) {
e.stopEvent();
return false;
}
}
}

});?


Regards,
Scott.

oturkan
2 May 2012, 12:03 PM
onRowContextMenu: function (grid, rowIndex, e) {
e.stopEvent();
var selModel = this.getSelectionModel();
if (selModel instanceof Ext.grid.RowSelectionModel) {
if (!selModel.isSelected(rowIndex)) {
selModel.selectRow(rowIndex);
this.fireEvent('rowclick', this, rowIndex, e);
}
this.contextMenu.showAt(e.getXY());
}
}


this code works extjs 3.0 doesnt work ext4.0

oturkan
2 May 2012, 12:06 PM
i forget thank you before reply

oturkan
2 May 2012, 12:53 PM
listeners: {
'itemcontextmenu': function (grid, record, item, index, e) {
e.stopEvent();
var selModel = this.getSelectionModel();
if (selModel instanceof Ext.selection.RowModel) {
if (!selModel.isSelected(record)) {
selModel.select(record);
this.fireEvent('itemclick', this, record, item, index, e);
}
this.contextMenu.showAt(e.getXY());
}
}
}


this code works for extjs 4.0

thanks for replay