This is a migrated thread and some comments may be shown as answers.

Initial hidden button

2 Answers 67 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
mzn developer
Top achievements
Rank 1
mzn developer asked on 04 Nov 2008, 04:46 PM
Hello,

Is there a good way to hide a button on the toolbar initially and show it through javascript?  I tried the Visible property but then the button control isn't put on the page so the only way to show it would be through a postback. 
I currently have it working by running javascript in the body onLoad but that causes the hidden buttons to show for a split second (or more on a slow machine/connection) before the javascript runs and hides them.

The scenario where I'm trying to use this is where we display data and we also have an Edit mode to update that data.  We want an Edit button displayed initially and when you click edit a javascript function is called where we will switch to an edit mode with the fields and also hide the Edit button and show a Save and Cancel button on the toolbar.

Any help is appreciated.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Erjan Gavalji
Telerik team
answered on 04 Nov 2008, 06:03 PM
Hi,

You can use the following approach:
<telerik:RadToolBarButton style="display:none"... />

<script type="text/javascript">
   function makeButtonVisible()
   {
       var toolBar = $find("<%=RadToolBar1.ClientID%>");
       var button = toolBar.get_items().getItem(0);
       button.set_visible(true);
   }
</script>


I hope this helps.

Kind regards,
Erjan Gavalji
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mzn developer
Top achievements
Rank 1
answered on 04 Nov 2008, 07:14 PM
I had tried that previously but now I see the issue.  I'm currently on version 2008.1.619 and I see an issue that was fixed with the 2008.2.826 release for the display:none style being applied to the main element instead of the link element.  That's why I couldn't get it to work correctly.

Time to upgrade.  Thanks for the help.
Tags
ToolBar
Asked by
mzn developer
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
mzn developer
Top achievements
Rank 1
Share this question
or