-
Tree Panel with renderer
I have a tree panel with a single column(supposed to be of kind treecolumn). This column is going to show the text for each node as well as some icons(kind of edit, delete) for each node.The icon to be shown is dependent on some business logic.
Each icon has a specific functionality and that is to be handled through a controller. I am using a MVC architecture application.
I have tried putting the icons with events in "items" property of the treecolumn, but thats not working.
If by using a renderer function for the treecolumn, I am not able to attach event handlers with the icons.
Please help.
Thanks
Kali
-
What about a 'treegrid' setup with a column dedicated to the action button using the actioncolumn xtype?
Similar to what you see here:
http://docs.sencha.com/ext-js/4-1/#!/example/tree/treegrid.html
Only sounds like you'd want to look at the actioncolumn API example to show how to modify the icon based on business logic.
-
Try to see if this will help:
Code:
var tree = Ext.create('Ext.tree.Panel', {
renderTo: Ext.getBody(),
width: 400,
height: 200,
store: treeStore,
columns: [{
xtype: 'treecolumn',
dataIndex: 'text',
flex: 1,
renderer: function(value){
return [
'<img src="images/icon-modify-16x16.png" action="modify" />',
'<img src="images/icon-delete-16x16.png" action="delete" />',
' ', value
].join('');
}
}],
listeners: {
itemclick: function(view, record, item, index, event){
var action = event.target.getAttribute('action');
if(action){
this.fireEvent(action, view, record, index);
}
},
// START DEBUG
modify: function(){
console.log('modify', arguments)
},
delete: function(){
console.log('delete', arguments)
}
// END DEBUG
}
});
-
Hey Vietits,
This is exactly what I was looking for.
This is really a gr8 help to me. It was kind of a show stopper for me.
U saved me .
Thanks again & Cool !!!