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

Set_visible(false) on page load

1 Answer 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen Whitaker
Top achievements
Rank 1
Stephen Whitaker asked on 31 Aug 2010, 11:42 AM
I am rendering a RadGrid with column which contains a dynamically insert control depending on row data type (i.e. if a row contains a date, the edit column will have a datepicker injected into it on Item_databind).  However, I want the control to load with its visibility set to false until the user clicks a radiobutton next to it.

I am trying to figure out how the telerik controls set visibility through jquery.  I would ideally like the control to be invisible until some jquery is fired which i thought i could accomplish by setting the display style attribute to display:none or display:hidden when the control is rendered.  This works, but the subsequent call to set_visible on the control does not make it visible again.

Could someone explain what selector and attribute is used when this method is called so that i can make the control invisible client side until i call set_visible on it?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 01 Sep 2010, 09:47 AM
Hello Stephen,

Generally, you should show and hide the datepicker using the same method. I recommend the following technique. I have deliberately used programmatic approach, similar to the one that you can use in RadGrid_ItemDataBound.

By the way, there is no such thing as display:hidden.

http://webdesign.about.com/od/css/f/blfaqhidden.htm

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void Page_Load(object sender, EventArgs e)
    {
        RadDatePicker1.DateInput.ClientEvents.OnLoad = "function(sender, args){window.setTimeout(function(){sender.get_owner().set_visible(false);},1);}";
 
        Button1.OnClientClick = "return togglePicker('" + RadDatePicker1.ClientID + "');";
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<asp:Button ID="Button1" runat="server" Text="Show RadDatePicker" />
 
<br /><br />
 
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" />
 
<script type="text/javascript">
 
function togglePicker(id)
{
    var picker = $find(id);
    if (picker)
    {
        picker.set_visible(!picker.get_visible());
    }
    return false;
}
 
</script>
 
</form>
</body>
</html>


All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Stephen Whitaker
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or