PDA

View Full Version : how to add action on Split button



Prashant0104
26 Sep 2012, 3:06 AM
Hi,
How can I add click handler for split button present in panel grid in Controller? On handler I want to know which rowIdex was clicked, and which menuitem of split button is clicked.

I am using Extjs 4.1

In grid panel I am using actioncolumn to show split button. Following is the code for that.

How can I add handler for split button in Controller? what will be the reference selector for split button menu in the controller, so that I can put click handler there.


columns: [
{
xtype: 'actioncolumn',
width:100,
renderer: function (v, m, rec) {
var id = Ext.id();
Ext.defer(function () {
Ext.create('Ext.button.Split', {
renderTo: id,
text: 'Action',
menu: new Ext.menu.Menu({
items: [
{ xtype: 'menuitem',text: 'View'},
{ xtype: 'menuitem',text: 'Edit',
handler: function(){
alert(" clicked on Edit");
me.viewSplitBtnClicked(rec);
}
},


]
})


});
}, 50);


return Ext.String.format('<div id="{0}"></div>', id);
}
}

]

sword-it
26 Sep 2012, 6:44 AM
Hi,

You can simply give action config to the Ext.menu.Menu items like-




menu: new Ext.menu.Menu({
items: [
{text: 'Item 1', action:'Save', handler: function(){ alert("Item 1 clicked"); }},
{text: 'Item 2', action:'update', handler: function(){ alert("Item 2 clicked"); }}
]
})
});