Premium support for our pure JavaScript UI components


Post by davidb »

Hello,

We need to show different menu items depending on the data in the row.. For example don't show the first item 'View Contract Notes' if a field value = x..

Thanks!

     type: 'widget',
                field: 'widget',
                align: 'center',
                cellCls: 'b-buttoncell',
                tooltipRenderer: false,
                locked: true,
                resizable: false,
                width: 60,
                widgets: [{
                    type: 'button',
                    cls: 'b-transparent',
                    menuIcon: null,
                    icon: 'b-icon b-fa-ellipsis-h',
                    menu: {
                        items: [{
                            text: 'View Contract Notes',
                            icon: 'b-fa-file-contract',
                            onItem({item, menu}) {
                                var rowRecord = menu._owner.cellInfo.record;
                                self.navigateToUrl(self.generateContractNotesURL(rowRecord.data.securityCode));
                            }
                        }, {
                            text: 'View Company Profile',
                            icon: 'b-fa-building',

                        onItem({item, menu}) {
ETC

Post by alex.l »

Hi,

You have access to widgets and record in renderer method. See docs https://bryntum.com/products/gantt/docs/api/Grid/column/WidgetColumn#config-renderer
Define a renderer and adjust widgets as you need according to record data.

                type: 'widget',
                field: 'widget',
                align: 'center',
                cellCls: 'b-buttoncell',
                tooltipRenderer: false,
                locked: true,
                resizable: false,
                width: 60,
                widgets: [{
                    type: 'button',
                    cls: 'b-transparent',
                    menuIcon: null,
                    icon: 'b-icon b-fa-ellipsis-h',
                    menu: { .... },
                }],
                renderer ({ widgets, record }) {
                    const btn = widgets[0];
                    btn.menu.getAt(0).hidden = record.get('hideBtnField');
                
}

All the best,
Alex


Post Reply