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

Change the style of the selected node client-side

1 Answer 213 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Polaris431
Top achievements
Rank 1
Polaris431 asked on 12 Aug 2009, 05:28 PM
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.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Aug 2009, 04:27 PM
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.
Tags
TreeView
Asked by
Polaris431
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or