Search code examples
extjsextjs6.2

How i can render different icon in one column based on store data?


I have 2 icons which need to display according to my grid data in the same column.

Trying condition with this.store.on('load', function(){... but dont have an idea to get it works

columns.push({
                xtype: 'actioncolumn',
                menuText: t('compare_version'),
                width: 35,
                items: [{
                tooltip: t('icon_compare_version'),
                icon: "/bundles/pimcoreadmin/img/flat-color-icons/info.svg",
                handler: this.compareVersion.bind(this),
                renderer: function(test, test1, test2){
                    return test;
                }
            }]
            });

            columns.push({
                xtype: 'actioncolumn',
                menuText: t('compare_image_version'),
                width: 35,
                items: [{
                    tooltip: t('icon_compare_image_version'),
                    icon: "/bundles/pimcoreadmin/img/flat-color-icons/picture.svg",
                    handler: this.compareImageVersion.bind(this)
                }]
            });

Please help. Thanks


Solution

  • Got it finally after some workaround

    columns.push({
                    xtype: 'actioncolumn',
                    width: 35,
                    dataIndex: 'objType',
                    renderer: function (value, rowIndex, record) {
                        if (value == 'object') {
                            rowIndex.tdCls = 'icon'
                        }
                        else{
                            rowIndex.tdCls = 'img'
                        }
                    },
                    items: [{
                        tooltip: t('icon_compare_version'),
                        icon: "/bundles/pimcoreadmin/img/flat-color-icons/info.svg",
                        handler: this.compareVersion.bind(this),
                        iconCls: 'compare-v'
                    },
                    {
                        tooltip: t('icon_compare_image_version'),
                        id:'compare-i',
                        icon: "/bundles/pimcoreadmin/img/flat-color-icons/picture.svg",
                        handler: this.compareImageVersion.bind(this),
                        iconCls: 'compare-i'
                    }]
                });