Results 1 to 3 of 3

Thread: [7.1 Modern] Download button or tool in grid with summary

  1. #1
    Ext JS Premium Member
    Join Date
    May 2010
    Posts
    2

    Default [7.1 Modern] Download button or tool in grid with summary

    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):

    Code:
    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:

    Code:
    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?

  2. #2
    Sencha User
    Join Date
    Oct 2018
    Location
    Noida
    Posts
    67

    Default

    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/...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

  3. #3
    Ext JS Premium Member
    Join Date
    May 2010
    Posts
    2

    Default

    Hi,

    Using ownerCmp works! Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •