Change the style of the selected node client-side

2 posts, 0 answers
  1. Polaris431
    Polaris431 avatar
    70 posts
    Member since:
    May 2007

    Posted 12 Aug 2009 Link to this post

    How can I change the style of the selected node in Javascript? The treeview has a set_cssClass method but that changes the style of the node and not the selection itself. If you use set_cssClass and change the style using set_cssClass and then select a different node, I will see the node has changed its style. What I want though is that WHILE the node is selected, I change the style of the selection itself. As soon as the selection is made on a different node, the style of the selection needs to revert back to its original css while the node that had the style changed remains changed. This is needed to implement a cut/paste function where the node being cut has a different style. When the user cuts the node using ctrl-x, I need to modify the selection immediately so that the user sees right away that the selected node is being cut.
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Aug 2009 Link to this post

    Hi Polaris431,

    You can set the selectedCssClass. Here is a short demo:

        <style type="text/css">
            .Selected .rtIn
            {
                color: red !important;
            }
        </style>

        <telerik:RadTreeView runat="server" ID="RadTreeView2" Height="100px" Width="200px"
            Style="overflow: hidden">
            <Nodes>
                <telerik:RadTreeNode Text="Node1" />
            </Nodes>
        </telerik:RadTreeView>

        <script type="text/javascript">
            function pageLoad() {
                var treeView = $find("<%=RadTreeView2.ClientID %>");
                var node = treeView.get_nodes().getNode(0);
                node.set_selectedCssClass("Selected");
                node.select();
            }
        </script>

    Regards,
    Atanas Korchev
    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.
Back to Top