PDA

View Full Version : [7.1 Modern] Download button or tool in grid with summary



Marc Kramis
20 Feb 2020, 7:41 AM
Hi,

I'd like to add a download button or tool to a grid column. The simplest way seems to be to use Ext.Tool (eventhough the download type is missing and would need a custom subclass):


Ext.define('sample.view.SampleGrid', {
extend: 'Ext.grid.Grid',

plugins: {
gridsummary: true
},
...

columns: [
...
{
text: 'Tool',
cell: {
tools: {
print: 'onSampleDownload'
}
}
}
]

})
;

However, the tool also appears in the SummaryRow and I cannot find a way to disable it there.

Another way would be to add a button by replacing the cell above with:



cell: {
xtype: 'widgetcell',
widget: {
xtype: 'button',
iconCls: 'x-fa fa-download',
handler: function (value) {
console.dir(value);
}
}
}


This is the better icon and it does not appear in the SummaryRow. However, how could I access the id/record of the row where the button was clicked?

praveensaini23
21 Feb 2020, 3:19 AM
Hi Marc,

While creating cell widgets for columns, extjs is injecting ownerCmp to the widget itself. You can see createCell function definition in below url -
https://docs.sencha.com/extjs/7.1.0/modern/src/Column.js.html

So you can get the record in cell width button handler like - btnRef(this).ownerCmp.getRecord().
You can see working example in below fiddle -

https://fiddle.sencha.com/#fiddle/33t7&view/editor

Marc Kramis
21 Feb 2020, 12:01 PM
Hi,

Using ownerCmp works! Thank you :)