widgetcolumn:将小部件的可见性绑定到 dataIndex
widgetcolumn: bind visibility of widget to dataIndex
我有一个包含按钮的小部件列:
xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
xtype: 'button',
text: 'Update key',
hidden: '{!record.canUpdateKey}'
}
我只想在记录中显示canUpdateKey
为真的按钮;但这并不像缩进那样工作。 Relevant fiddle
在您的按钮小部件中,试试这个:
listeners:{
render:function(btn){
if(!btn.getWidgetRecord().data.canUpdateKey)
btn.hide();
}
}
来自 widget 配置文档:
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.
所以你应该改用 bind,像这样:
xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
xtype: 'button',
text: 'Update key',
bind: {
hidden: '{!record.canUpdateKey}'
}
}
我有一个包含按钮的小部件列:
xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
xtype: 'button',
text: 'Update key',
hidden: '{!record.canUpdateKey}'
}
我只想在记录中显示canUpdateKey
为真的按钮;但这并不像缩进那样工作。 Relevant fiddle
在您的按钮小部件中,试试这个:
listeners:{
render:function(btn){
if(!btn.getWidgetRecord().data.canUpdateKey)
btn.hide();
}
}
来自 widget 配置文档:
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.
所以你应该改用 bind,像这样:
xtype:'widgetcolumn',
dataIndex: 'canUpdateKey',
itemId:'updateKey',
width:120,
widget: {
xtype: 'button',
text: 'Update key',
bind: {
hidden: '{!record.canUpdateKey}'
}
}