2
我有以下JavaScript
的代碼。通過使用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);
}
});
}
}]
}]
});
正如你所看到的網格沒有源。我想保留Save
按鈕的代碼,但不顯示,直到我設置源:grid.setSource("data")
。
在其他一些功能中,我會得到data
並將其設置爲grid's source
,然後我想使按鈕可見。感謝
如果我想先顯示,然後隱藏以顯示其他隱藏按鈕? – Brian
如果我的理解正確,你應該能夠使用上面的答案很容易地提出解決方案。添加另一個不帶'hidden:true'的按鈕,給它一個唯一的ID,然後使用'grid.down('#otherButton')。hide()'。 – kevhender