Reputation: 10030
I have a toolbar having one button as follows
{ text: 'Save', tooltip: 'Save report', iconCls: 'some-cls', handler: 'somehandler' }
I want to hide this button for some condition.
for this I am getting toolbar items and hide/show the items as follows.
showHideToolbarItems: function(titles)
{
tbarItems = getToolbarItems(); // Getting items successfully
for (var i = 0, len = tbarItems.count; i < len; i++) {
var item = tbarItems.itemAt(i);
if (titles.indexOf(item.text) > -1)
{
item.setVisible(false);
}
}
}
I am calling this function as showHideToolbarItems(['Save']);
But I am getting error setvisible is not a function.
What I am doing wrong here
Upvotes: 0
Views: 914
Reputation: 900
You can add reference to your button for faster access and right approach
{
text: 'Save',
reference: 'saveBtn',
tooltip: 'Save report',
iconCls: 'some-cls',
handler: 'somehandler'
}
and inside your viewController:
showHideToolbarItems: function(titles)
{
var view = this.getView(),
saveButton = view.lookupReference('saveBtn');
saveButton.hide();
//saveButton.show();
}
Upvotes: 2