[英]how to make button invisible and visible in grid?
I have the following JavaScript
code. 我有以下JavaScript
代码。 By using ExtJS
I have docked button
in my grid and I want to keep it invisible when the grid is empty. 通过使用ExtJS
我将docked button
在网格中,并且当网格为空时我希望使其不可见。
var grid = Ext.create('Ext.grid.property.Grid',
{
// width: '100%',
// height: '100%'
dockedItems:
[{
xtype: 'toolbar',
id: 'save_t',
dock: 'bottom',
ui: 'footer',
items: ['->',
{
text: 'Save',
handler: function()
{
// get values
var gridvalues = this.up('propertygrid').getSource();
alert(gridvalues.Version);
// send AJAX request
Ext.Ajax.request({
url: '../php/updateVars.php?v=' + JSON.stringify(gridvalues),
success: function(response)
{
var obj = JSON.parse(response.responseText);
// alert(Object.prototype.toString.apply(obj));
},
failure: function(response)
{
alert('server-side failure with status code ' + response.status);
}
});
}
}]
}]
});
As you can see the grid has no source. 如您所见,网格没有源。 I want to keep the code for Save
button but not to show until I set the source: grid.setSource("data")
. 我想保留“ Save
按钮的代码,但在设置源之前不显示它: grid.setSource("data")
。
In some other function I will get the data
and set it as grid's source
, then I want to make the button visible. 在其他功能中,我将获取data
并将其设置为grid's source
,然后我想使按钮可见。 Thanks 谢谢
You should define your button as hidden
for the initial config, and assign it an itemId
: 您应该为初始配置将按钮定义为hidden
,并为其分配一个itemId
:
{
text: 'Save',
itemId: 'saveButton',
hidden: true,
handler: function() { ... }
}
Then, when you are ready to show it, you can use this: 然后,当您准备显示它时,可以使用以下命令:
grid.down('#saveButton').show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.