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

how to set radnumerictextbox set_visible(false) in item data bound

1 Answer 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 12 Apr 2011, 11:44 AM
Hi,

I have radcombobox in my radgrid. i want to hide the radnumerictextbox in default. clicking checkbox want to display in client side. client side when i am using same code set_visible(false) and set_visible(true). but i want to set  set_visible(false) for radnemerictext box.

Please give me a tips.

Thanks in advance,
Dhamu.

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 15 Apr 2011, 09:40 AM
Hi dhamodharan,

You need to register a startup script from the server that will hide the input using javascript when the page loads. Here is a test page:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Tickets_327691_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" Width="800px"
            OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false">
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <input type="button" value="toggle numeric box" onclick="toggleNumericBox(this, event);" />
                            <telerik:RadNumericTextBox ID="NumberBox" runat="server" OnLoad="NumberBox_Load">
                            </telerik:RadNumericTextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
 
        <asp:Button ID="Button1" runat="server" Text="Postback" />
 
        <script type="text/javascript">
            function toggleNumericBox(button, args)
            {
                var numBox = $telerik.findControl(button.parentNode, "NumberBox");
                numBox.set_visible(!numBox.get_visible());
            }
        </script>
    </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Drawing;
 
public partial class Tickets_327691_Default : System.Web.UI.Page
{
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = MyData.BusinessDataStorage.GetData().Take(5);
    }
 
    protected void NumberBox_Load(object sender, EventArgs e)
    {
        RadNumericTextBox numberBox = sender as RadNumericTextBox;
 
        ScriptManager.RegisterStartupScript(Page,
            typeof(Page),
            "Hidden:" + numberBox.ClientID,
            String.Format("Sys.Application.add_load(function(){{ $find('{0}').set_visible(false); }});", numberBox.ClientID),
            true);
    }
}

In the above test page, I use the Load event of the RadNumericTextBox to get its ClientID and register a startup script. The script finds  the client component and uses its set_visible() method to hide the component once it is loaded. You can then use a button to toggle the input visibility again with the set_visible() method.


Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or