extjs4 Change action column icon dynamically
Asked Answered
M

2

5

I'm using getClass to render the icon in the action column.

{
xtype: 'actioncolumn',
id:'actionColumnGridUsers',
width: 30,
hideable: false,
items: ['->',
    {
        getClass: function (v, meta, rec)
        {
            if (rec.get('nameUser') != '') return 'icon-edit';
            else return 'icon-add';
        }

    }
}

And the css code:

.icon-add { background-image: url("../images/add.png"); }
.icon-edit { background-image: url("../images/edit.png"); }

The code seems to be correct, but the icon is not shown. What I'm missing?

Medico answered 7/5, 2013 at 10:3 Comment(2)
need to know, what problem are you facing?Compte
@PHP: the icon is not showedMedico
M
7

I have resolved it like this:

{
    xtype: 'actioncolumn',
    id:'actionColumnGridUsers',
    width: 30,
    hideable: false,
    items:
        [{
            getClass: function(v, meta, rec) {
                if (rec.get('nameUser') != '') {
                    this.items[0].tooltip = 'del';
                    return 'icon-del';
                } else {
                    this.items[0].tooltip = 'edit';
                    return 'icon-edit';
                }
            }
        }]
}

And the css code:

.x-action-col-cell img.icon-del {
background-image: url("../images/delete.png");
}
.x-action-col-cell img.icon-edit {
    background-image: url("../images/add.png");
}
Medico answered 7/5, 2013 at 13:37 Comment(0)
G
0

or you can try this :

iconCls: me.readOnly==true ? 'icon-view' : 'icon-edit',

Gauntlet answered 10/7, 2015 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.