Skip to content

Instantly share code, notes, and snippets.

@marcusschiesser
Created May 7, 2013 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusschiesser/5531014 to your computer and use it in GitHub Desktop.
Save marcusschiesser/5531014 to your computer and use it in GitHub Desktop.
Buttons with action handlers in a datagrid in ExtJS 4.2
Ext.onReady(function () {
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'}
]
});
var store = Ext.create('Ext.data.Store', {
model: 'User',
data: [
{name: 'Homer'},
{name: 'Maggie'}
]
});
var view = Ext.create('Ext.view.View', {
renderTo: Ext.getBody(),
store: store,
tpl: [
'<tpl for=".">',
'<div class="user">',
'<span>{name}</span>',
'<input type="button" class="button-action" value="action" />',
'</div>',
'</tpl>'
],
listeners: {
itemmousedown: function (me, record, item, index, e) {
var className = e.target.className;
if ("button-action" == className) {
alert("Clicked action on item: " + record.get('name'));
}
}
},
itemSelector: 'div.user'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment