RadTreeView, RadComboBox and PostBack

2 posts, 0 answers
  1. Marco Minerva
    Marco Minerva avatar
    3 posts
    Member since:
    Oct 2008

    Posted 09 Oct 2008 Link to this post

    Hi all!

    I have created a RadComboBox with a RadTreeView, like the one in the example that is shipped with RadControls. Now I would like that the text of the ComboBox is persisted between PostBack. Is it possible?

    Thanks.
    --
    Marco Minerva [MCPD], marco.minerva@gmail.com
    http://blogs.ugidotnet.org/marcom
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 09 Oct 2008 Link to this post

    Hello Marco,

    You can store the text of the Selected Node as a Value of the one Item of the ComboBox. Using track/commitChanges in this case will persist the Value across postbacks. On load of the ComboBox you can restore its text from its Item's Value.

    <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px" 
        ShowToggleImage="True" Skin="WebBlue" style="vertical-align:middle;" 
        OnClientLoad="comboLoad"

                                  function comboLoad(sender, eventArgs) 
                { 
                    sender.set_text(sender.get_items().getItem(0).get_value()); 
                } 
                 
                function nodeClicking(sender, args) 
                { 
                    var comboBox = $find("<%= RadComboBox1.ClientID %>"); 
                     
                    var node = args.get_node() 
                     
                    comboBox.set_text(node.get_text()); 
                     
                    comboBox.trackChanges(); 
                    comboBox.get_items().getItem(0).set_value(node.get_text()); 
                    comboBox.commitChanges(); 
                     
                    comboBox.hideDropDown(); 
                } 

    I hope this helps.

    Greetings,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top