Uriel
Uriel

Reputation: 466

Extjs get actioncolum item properties inside getClass

I hope I can be clear enough to explain my issue:

I have some actioncolumn icons and i want to re-use the same getClass function cause it does almost the same: hidde for some row types.

My items are like this:

actions: {
    print: {
        iconCls: 'fa fa-print info-icon',
        tooltip: 'Print',
        getClass:'rowClassByType'
    },
    download: {
        iconCls: 'fa fa-download info-icon',
        tooltip: 'Download',
        getClass:'rowClassByType'
    },
    view: {
        iconCls: 'fa fa-file-o info-icon',
        tooltip: 'View',
        handler: 'transDetByIconClick',
    },
    mail: {
        iconCls: 'fa fa-envelope-o info-icon',
        tooltip: 'Message',
        test: 'test',
        handler: '',
        getClass:'rowClassByType'

    }
},

And I want to hidde all icons, except 'view' if the row has some certain value on certain column, so I did like this on my controller:

rowClassByType: function(v, metadata, r, rowIndex, colIndex, store, view) {
    if (r.data.description !== 'IN') {
        return 'x-hidden-visibility';
    }
    return 'fa '+icon+' info-icon';
},

Example: How to keep the original class for rows of type 'B'?:

https://fiddle.sencha.com/#view/editor&fiddle/2kj7

I know I can do this, but I don't want to:

https://fiddle.sencha.com/#view/editor&fiddle/2kj9

Can someone give me a hint about the best way to do this?

Upvotes: 0

Views: 339

Answers (1)

hwsw
hwsw

Reputation: 2606

This should work:

   getClass: function (v, meta, r, rowIndex) {
                        var cls = 'x-fa fa-' // fallback
                        var type = r.get('type');
                        if (type === 'a') {
                            cls += 'warning';
                        } else if (type === 'b') {
                            cls += 'cog';
                        } else if (type === 'c') {
                            cls = '';
                        }
                        return cls;
                    }

https://fiddle.sencha.com/#view/editor&fiddle/2kj8


If you need a reference to your action, this should work:

isActionDisabled: function (v, r, c, item){
                    var cls = item.iconCls;
                    if(r === 2){
                        cls = '';
                    }
                     if(r === 1){
                        cls = 'x-fa fa-warning';
                    }
                     if(r === 4){
                        cls = 'x-fa fa-eye';
                    }
                    item.iconCls = cls;
                    return false;
                }

https://fiddle.sencha.com/#view/editor&fiddle/2kja

Upvotes: 1

Related Questions