Reputation: 20224
I have a grid in which I am adding active dom content into each cell. As of now, I am adding it as html text inside the column renderer:
renderer:function(data) {
str = "";
Ext.each(data,function(paragraph,i) {
str += '<div onclick="Ext.getCmp(\'grid\').paragraphClick('+paragraph.get("Id")+');">'+paragraph.get("Text")+'</div>'
});
return str;
}
I should mention that data
is a record field which contains another list of records.
Now, I guess you'll call this the "worst ExtJS code you have ever seen". That's fair.
But how would I do this in an ExtJS-conforming way, using Ext elements and listeners?
Upvotes: 0
Views: 649
Reputation: 30082
Use the cellclick event, then check the target:
renderer: function(v) {
return '<div class="foo">' + v + '</div>';
}
listeners: {
cellclick: function(view, td, cellIndex, record, tr, rowIndex, e) {
if (e.getTarget('.foo') {
// clicked on foo, use record data to give you context
}
}
}
Upvotes: 1