Hide elements based on scheduler state

5 posts, 1 answers
  1. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 13 May 2009 Link to this post

    I have a few combo boxes above my calendar that allow users to select resources.  My question is how can I hide those combo boxes when the user goes to the advanced edit page? 
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 18 May 2009 Link to this post

    Hello Matt,

    Here is how you can achieve that:

    1. Subscribe the on OnClientFormCreated event: OnClientFormCreated="onClientFormCreated"
    2. Add the following javascript code to your page:

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    <script type="text/javascript"
    function onClientFormCreated(sender, e) 
        shouldBeEnabled = false
     
    var shouldBeEnabled = true
     
    function pageLoad() 
        toggleCombo(shouldBeEnabled); 
     
    function toggleCombo(state) 
        var combo = $find("<%= RadComboBox1.ClientID %>"); 
        switch (state) 
        { 
            case true: combo.enable();break
            case false: combo.disable(); shouldBeEnabled = truebreak
        } 
    </script>         
    </telerik:RadScriptBlock>  

    I hope this helps.

    Regards,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 18 May 2009 Link to this post

    Wow, that's slick.  That disables the box.  What javascript would I use to hide the combobox?
  5. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 19 May 2009 Link to this post

    Hi Matt,

    Ah, yes, here is the modified toggleCombo function:

    function toggleCombo(state) 
        var combo = $find("<%= RadComboBox1.ClientID %>"); 
        switch (state) 
        { 
            case truecombo.get_element().style.visibility = ""break
            case falsecombo.get_element().style.visibility = "hidden"; shouldBeEnabled = truebreak
        } 


    Best wishes,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 19 May 2009 Link to this post

    Thanks for the code!  Took what you gave me, modified it a little bit and it works great.  Here's my modified code just in case anyone can use it:

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
    <script type="text/javascript"
        //<![CDATA[
    function onClientFormCreated(sender, e) 
        shouldBeEnabled = false
    }

    var shouldBeEnabled = true
     
    function pageLoad() { 
        toggleCombo(shouldBeEnabled); 
     
    function toggleCombo(state) { 
        var combo = document.getElementById('tblComboBoxes'
        switch (state) { 
            case true: combo.style.visibility = ""; combo.style.display = ""break
            case false: combo.style.visibility = "hidden"; combo.style.display = "none"; shouldBeEnabled = truebreak
        } 
    }  
     
        //]]>  
    </script>         
    </telerik:RadScriptBlock>  

    I have a table with id="tblComboBoxes' which include multiple label and comboboxes.  This hides the entire table when the edit form is called.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017