Pergunta

Using 4.0.6 I have a gridpanel with an actioncolumn that has two items, a delete button and and view button. The delete button is disabled but there are some circumstances where it needs to be enabled (if a user is an admin). So I am trying to enable it in code.

Here's the view:

Ext.define('PP.view.person.List', {
extend: 'Ext.grid.Panel',
alias: 'widget.personlist', 
title: 'Current people',
store: 'People',
columnLines: true,

initComponent: function () {
    this.columns = [
        { header: 'Id', dataIndex: 'personId', flex: 1, sortable: true },
        { header: 'Title', dataIndex: 'title', flex: 1 },
        { header: 'Name', dataIndex: 'name', flex: 1},
        { xtype:'actioncolumn',
            items:[
                {icon:'cross.gif',disabled:true,handler:function(){alert('delete pressed');}},
                {icon:'tick.gif',handler:function(){alert('view pressed');}}
            ]
        }
    ];

    this.callParent(arguments);
}

});

and the controller function I'm using to enable:

enableDel: function () {
    var view = Ext.widget('personlist');
    view.down('actioncolumn').enableAction(0);
}

but I am getting an error inside the extjs enableAction function on the line that starts

me.up('tablepanel').el.select

the el is undefined. The column doesn't get enabled either. Can anyone tell me what I'm doing wrong or post an example that works? If I specify

renderTo: Ext.getBody()

in the view I don't get the error any more but the column still doesn't enable. So I think it must be something to do with rendering but I'm so new to this I haven't a clue where to start.

Foi útil?

Solução

Generally when el is undefined it means that you are attempting to access it before the component is rendered. When does your enableDel function get called? You might want to try putting it in an afterrender listener.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top