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

Initializing Input.Style=display:none breaks set_visible(a)

4 Answers 165 Views
Input
This is a migrated thread and some comments may be shown as answers.
Wyatt
Top achievements
Rank 1
Wyatt asked on 13 May 2010, 10:38 PM

I wanted a RadNumericTextBox and a RadDateTimePicker to be loaded hidden, but later be made visible via javascript.  Perhaps the most elegant solution is to use AJAX, but in my case I want the hide and unhide to always happen instantly, so javascript is the best choice.  I found a work around for both, but it's ugly.  Perhaps I overlooked something.  Perhaps a future release can handle this issue better.  Here's my solution.

Initialization

Protected Overrides Sub CreateChildControls()  
...  
    RadDateTimePicker1.Style("display") = "none" 
...  
    RadNumericTextBox1.ClientEvents.OnLoad = "function(){$find(""" & RadNumericTextBox1.ClientID & """).set_visible(false);}"  
...  
End Sub 

Javascript display function
var display = function(control, visible) {  
    if (control.style) { //normal  
        control.style.display = visible ? "" : "none";  
    }  
    else {  
        if (control._numberFormat) { //numeric  
            control.set_visible(visible);  
        }  
        else { //datetime  
            $get(control.get_id() + "_wrapper").style.display = visible ? "inline-block" : "none";  
        }  
    }  

As odd as this approach is, it's the most straight forward one I could find.  Any better suggestions?

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 14 May 2010, 07:00 AM
Hello Wyatt,

The problem is caused by a couple of specifics of the RadInput textboxes and RadDatePickers, so your workaround is OK. In the future we may research how to make showing these controls more intuitive when they have been initially hidden.

Another option in your case is to toggle the display style of some parent element of the textboxes / pickers.

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
Wyatt
Top achievements
Rank 1
answered on 14 May 2010, 01:56 PM
Thanks for the feedback!  I tried using a couple different parent elements (HtmlGenericControl("div") and Table) without success.  I was unable to find them via Control.ClientID with $get, document.getElementById, or $find.  I'm guessing this had something to with the fact that these controls are part of a RadTreeView templated node.  AJAX shouldn't have been a factor, because I tested the initial page load.  In the same templated node, $find worked for RadNumericTextBox and RadDateTimePicker, and $get worked for TextBox and LiteralControl.
0
Dimo
Telerik team
answered on 14 May 2010, 01:59 PM
Hi Wyatt,

$get() and document.getElementById() is the same thing. If it does not work for a generic HTML element, then the ID, passed as an argument is not correct.

Kind regards,
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
Wyatt
Top achievements
Rank 1
answered on 14 May 2010, 02:14 PM
I'm 20 minutes of certain that the id was correct.  I checked the HTML source.  I used the exact same methodology (i.e. Control.ClientID) to successfully access elements adjacent to the div and table in the same execution thread.  I realize you get many posts per day of developers insisting that the impossible is happening, because they have overlooked something.  Nevertheless, if some other possible problem other than an incorrect ID pops into your head, let me know.  Thanks!
Tags
Input
Asked by
Wyatt
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Wyatt
Top achievements
Rank 1
Share this question
or