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

RadNumericTextbox set_visible() not working

11 Answers 123 Views
Input
This is a migrated thread and some comments may be shown as answers.
Mansi
Top achievements
Rank 1
Mansi asked on 05 Jun 2010, 08:10 AM
Hi,

I am using radnumeric textboxes inside gridview, and trying to set their visiblity by javascript, but neither set_visible(), nor the .display='', is working.
I tried by taking a simple textbox outside the grid too, but for that also set_visible is not working.

Here is my code for the gridview textboxes.

  var   rows = document.getElementById('<%= grdTeeDetails.Clientid%>').rows;       
    for(i=1;i <rows.length;i++) 
            {                                  
                if(document.getElementById('ctl00_cphMainContent_grdTeeDetails_ctl02_txtLPar' + i) != null) 
               {  
                    document.getElementById('ctl00_cphMainContent_grdTeeDetails_ctl02_txtLPar' + i).style.visibility='visible';                
                    document.getElementById('ctl00_cphMainContent_grdTeeDetails_ctl02_txtLPar' + i).style.display='';       
                    txtLPar=$find(document.getElementById('ctl00_cphMainContent_grdTeeDetails_ctl02_txtLPar' + i).id);      
                    txtLPar.set_visible(true);     
                }                                 
           }               


There is not a single javascript bug, but the code is not working.


Thanks,
Mansi Shah

11 Answers, 1 is accepted

Sort by
0
Mansi
Top achievements
Rank 1
answered on 05 Jun 2010, 01:52 PM
Is there any solution for this?
0
Mansi
Top achievements
Rank 1
answered on 07 Jun 2010, 02:03 PM
Nobody to reply?
0
hari
Top achievements
Rank 1
answered on 08 Jun 2010, 08:43 AM
Hi Mansi,

I think the problem is with using document.getelementbyid().

Code below works well.
var txtbox = $find("<%= RadTextBox1.ClientID %>");
txtbox.set_visible(false);

 

0
Mansi
Top achievements
Rank 1
answered on 08 Jun 2010, 08:57 AM
Thanks for the reply.
But I have the radnumeric texboxes inside the gridview. How can I use var txtbox = $find("<%= RadTextBox1.ClientID %>"), in that case?
0
hari
Top achievements
Rank 1
answered on 08 Jun 2010, 10:29 AM
Hi,

Could you please post some more of your code.
0
Mansi
Top achievements
Rank 1
answered on 08 Jun 2010, 11:05 AM
 <asp:GridView ID="grdTeeDetails" runat="server" AutoGenerateColumns="False" ShowHeader="true" 
        ShowFooter="false" Width="950px"
        <HeaderStyle CssClass="pagelabel" /> 
        <Columns> 
            <asp:TemplateField HeaderText="Hole" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                ItemStyle-Width="29px"
                <ItemTemplate> 
                    <asp:Label ID="lblHole" runat="server" Text='<%# Eval("Hole") %>'></asp:Label> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="Par" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                ItemStyle-Width="29px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtSinglePar" width="25px" emptymessage="Par"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="SI" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                ItemStyle-Width="29px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtSingleSI" width="25px" emptymessage="SI"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="LPar" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                ItemStyle-Width="29px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtSingleLPar" width="25px" emptymessage="LPar"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="LSI" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                ItemStyle-Width="29px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtSingleLSI" width="25px" emptymessage="LSI"  
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-VerticalAlign="middle" ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee1" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar1" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI1" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar1" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI1" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee2" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar2" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI2" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar2" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI2" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee3" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar3" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI3" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar3" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI3" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee4" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar4" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI4" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar4" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI4" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee5" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar5" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI5" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar5" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI5" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee6" width="25px" emptymessage="Len" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar6" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI6" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar6" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI6" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ShowHeader="true" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="115px" 
                ItemStyle-Width="115px"
                <ItemTemplate> 
                    <telerik:radnumerictextbox runat="server" id="txtTee7" width="25px" emptymessage="Len" style="display:none">  
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtPar7" width="20px" emptymessage="Par" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtSI7" width="20px" emptymessage="SI" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLPar7" width="20px" emptymessage="LPar" style="display:none"
                                            </telerik:radnumerictextbox> 
                    <telerik:radnumerictextbox runat="server" id="txtLSI7" width="20px" emptymessage="LSI" style="display:none"
                                            </telerik:radnumerictextbox> 
                </ItemTemplate> 
            </asp:TemplateField> 
        </Columns> 
    </asp:GridView> 

This is the .aspx page code, and on a checkbox click, client side, calling a javascript which has been provided in my first post.
I just need to show/visible all the textboxes in the grid, if the checkbox is checked.



0
Dimo
Telerik team
answered on 10 Jun 2010, 09:16 AM
Hello Mansi,

So your question is how to obtain reference to the RadNumericTextBox client instances when the checkbox is (un)checked. One option is to subscribe the each RadNumericTextBox OnLoad client event and fill in an array, to be used later. Here is a simple demo.

Another option is to construct an Array of the client instances themselves, not just the IDs. In this way you will not need to execute $find() every time.


<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
  
<!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" />
 
<p>A list of RadNumericTextBoxes. (Un)check the checkbox to toggle their visibility.</p>
 
<p><asp:CheckBox ID="CheckBox1" runat="server" onclick="toggleVisibility(this)" Checked="true" /></p>
 
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" ClientEvents-OnLoad="SaveID" />
<br /><br />
<telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" ClientEvents-OnLoad="SaveID" />
<br /><br />
<telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" ClientEvents-OnLoad="SaveID" />
<br /><br />
<telerik:RadNumericTextBox ID="RadNumericTextBox4" runat="server" ClientEvents-OnLoad="SaveID" />
<br /><br />
<telerik:RadNumericTextBox ID="RadNumericTextBox5" runat="server" ClientEvents-OnLoad="SaveID" />
<br /><br />
<telerik:RadNumericTextBox ID="RadNumericTextBox6" runat="server" ClientEvents-OnLoad="SaveID" />
 
<script type="text/javascript">
 
var textboxIDs = new Array();
 
function SaveID(sender, args)
{
    textboxIDs.push(sender.get_id());
}
 
function toggleVisibility(checkbox)
{
    if (checkbox.checked)
    {
        setAllVisible(true);
    }
    else
    {
        setAllVisible(false);
    }
}
 
function setAllVisible(visible)
{
    for (var j = 0; j < textboxIDs.length; j++)
    {
        $find(textboxIDs[j]).set_visible(visible);
    }
}
 
</script>
 
</form>
</body>
</html>


Best wishes,
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.
0
Sonia
Top achievements
Rank 1
answered on 25 Sep 2014, 08:12 AM
Hello,
I have the same problem as Mansi,

RadNumericTextbox set_visible() does not work.

I have tried the solution proposed by Dimo and it does not work neither.

I have also tried to do that by using styles but with no success:
                RadNumericTextBox1._textBoxElement.style.cssText = show ? "display:inline;" : "display:none;";






0
Eyup
Telerik team
answered on 30 Sep 2014, 07:36 AM
Hi Sonia,

I've created a sample RadGrid web site to test the described behavior and on my side the mentioned method works as expected. Can you please run the attached application and let me know about the result?

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sonia
Top achievements
Rank 1
answered on 30 Sep 2014, 07:57 AM
Hi Eyup,

I have tried your solution and it does not work. When pressing button "Toggle NumBox", nothing happens.
I have tested it on IE11 and Chrome and the behaviour is the same.

Kind regards,
Sonia.
0
Eyup
Telerik team
answered on 03 Oct 2014, 06:52 AM
Hello Sonia,

Can you please verify whether you've tried the sample with the latest release version of the controls?

Looking forward to your reply.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Input
Asked by
Mansi
Top achievements
Rank 1
Answers by
Mansi
Top achievements
Rank 1
hari
Top achievements
Rank 1
Dimo
Telerik team
Sonia
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or