0

I have a widgetcolumn that contains a button:

xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
    xtype: 'button',
    text: 'Update key',
    hidden: '{!record.canUpdateKey}'
}

I only want to display the button where canUpdateKey is true on the record; but this does not work as indented. Relevant fiddle

Alexander
  • 19,906
  • 19
  • 75
  • 162

2 Answers2

1

From the widget config documentation:

The rendered component has a Ext.app.ViewModel injected which inherits from any ViewModel that the grid is using, and contains two extra properties: record and recordIndex

The widget configuration may contain a cfg-bind config which uses the ViewModel's data.

So you should use bind instead, like this:

xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
    xtype: 'button',
    text: 'Update key',
    bind: {
        hidden: '{!record.canUpdateKey}'
    }
}

Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/26ig

scebotari66
  • 3,395
  • 2
  • 27
  • 34
0

Inside your button widget, Try this:

listeners:{
                render:function(btn){
                    if(!btn.getWidgetRecord().data.canUpdateKey)
                    btn.hide();
                }
                }
Harshit Shah
  • 266
  • 2
  • 7