1

アイコンのみの2つのアクション列を持つEXTJSグリッドがあります。IsApproved = true の場合にアイコンを非表示にするようにレンダラーを設定するにはどうすればよいですか? this.columns[0].items[0].icon = ''; を試しました。this.columns が定義されていないというエラーが発生します。

columns: [
                    { header: 'Name', dataIndex: 'Name', flex: 1 },
                    { header: 'Login', dataIndex: 'Login', flex: 1 },
                    { header: 'Registered', dataIndex: 'RegisteredOn', flex: 1 },
                    { header: 'Invited', dataIndex: 'InvitationSent', flex: 1 },
                    { xtype: 'actioncolumn',
                        width: 40,
                        header: 'Invite',
                        tdCls: 'clickable',
                        renderer: function (value, metadata, record) {
                            if (record.get('IsApproved')) {
                               //HIDE ICON
                            } else {
                                //SHOW ICON
                            }
                        },
                        items: [{
                            icon: '/images/icon_email.png',
                            tooltip: 'Invite',
                            scope: this,
                            handler: this.inviteClick
                        }]
                    },
                    { xtype: 'actioncolumn', width: 40, header: 'Edit', tdCls: 'clickable', items: [{
                        icon: '/images/pencil.png',
                        tooltip: 'Edit',
                        scope: this,
                        handler: this.editClick
                    }]
                    }
                ],
4

1 に答える 1

3

私のやり方を試してみてください - あなたの条件が真なら、セルにアイコンを入れてください。他の状況では、あなたはしません:

                {
                    xtype: 'actioncolumn',
                    width: 70,
                    align: 'center',
                    dataIndex: 'yourDataIndex',
                    menuDisabled: 'true',
                    text: 'sometext',
                    sortable: false,
                    fixed: 'true',
                    renderer: function (value, metadata, record) {
                        if (record.get('IsApproved')) {
                            metadata.tdCls = 'mycss'
                        }
                    }
                }

あなたの状況に合わせてcssを追加してください:

.mycss {
    background-position:center  !important;
    width: auto !important;
    background-repeat: no-repeat;
    background-image: url("yourIcon.png") !important; 
}
于 2013-06-11T14:08:35.380 に答える