Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extjs4 Change action column icon dynamically

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?

like image 806
Aminesrine Avatar asked May 07 '13 10:05

Aminesrine


1 Answers

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");
}
like image 53
Aminesrine Avatar answered Oct 15 '22 05:10

Aminesrine