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

Show/hide RadToolBar control - javascript

3 Answers 358 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 2
Emil asked on 14 Dec 2012, 10:56 AM
Hello,

How can I show/hide the RadToolBar control using client-side javascript?

I've tried:
var toolBar = $find("<%=RadToolBar2.ClientID%>");
toolBar.set_visible(false);

and..

var toolBar = $find("<%=RadToolBar2.ClientID%>");
toolBar.hide;

Doesn't work!

Thank you!

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 14 Dec 2012, 09:04 PM
Hello Emil,

If you're using the latest version of the controls the set_visible function should work.
0
Emil
Top achievements
Rank 2
answered on 15 Dec 2012, 07:52 AM
Thank you Kevin!

I have two RadToolBar controls. I have a on/off button on RadToolBar1 which shows/hides the second toolbar (RadToolBar2).

It only works when the RadToolBar2 starts out as a visible control. When the RadToolBar2 Visible property is set to "False", the on/off button on RadToolBar1 doesn't work anymore.

Why?

Thanks,
Emil
0
Accepted
Kevin
Top achievements
Rank 2
answered on 15 Dec 2012, 02:45 PM
Hello Emil,

If the Visible property is set to false on the RadToolBar, or any control for that matter, they are not rendered in the browser, thus they don't exist on the client. This is the reason you can't toggle it's visibility because it doesn't exist on the client. I would suggest hiding it on the client using the OnClientLoad event of the first RadToolBar, instead of setting the Visible property of the control. So it could look something like this:

function OnClientLoad(sender, args) {
    var onOffButton = sender.findItemByValue("OnOffButton");
  
    if (onOffButton.get_value() == "Off") {
        $find("<%=RadToolBar2.ClientID%>").set_visible(false);
    }
}

I'm assuming you might to change this code if you're using a toggle button, but the general logic is there.

I hope that helps.
Tags
ToolBar
Asked by
Emil
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 2
Emil
Top achievements
Rank 2
Share this question
or