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

Clicking Node + Ctrl to multiple select does not fire NodeClick event

2 Answers 97 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
nfigueroa
Top achievements
Rank 1
nfigueroa asked on 22 Nov 2013, 07:30 PM
Hello All

I am trying to get the event TreeView1_NodeClick to fire.  When I click to select a single node there is no problem, but when I intend to select multiple nodes by clicking and holding ctrl or shift keys the event won't fire!

Is there any other event similar to achieve this?

Regards

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Nov 2013, 11:55 AM
Hi nfigueroa,

The RadTreeView NodeClick  will not fire when the  MultipleSelect property is  set to True. If the RadTreeView fires the NodeClick server event on every node click , then the user will not be able to select multiple nodes at once, because after the first click the page will postback. In this case you can use the  client-side events of RadTreeView OnClientNodeClicking and OnClientNodeClicked.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" MultipleSelect="true" OnClientNodeClicked="OnClientNodeClicked" OnNodeClick="RadTreeView1_NodeClick">
    <Nodes>
        <telerik:RadTreeNode runat="server" Text="Item1">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Item1.1">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Item1.2">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Item1.3">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeNode>
        <telerik:RadTreeNode runat="server" Text="Item2">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Item2.1">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Item2.2">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Item2.3">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeNode>
    </telerik:RadTreeView>

JavaScript:
<script type="text/javascript">
    function OnClientNodeClicked(sender, args) {
        alert("fired");
    }
</script>

Thanks,
Princy.
0
nfigueroa
Top achievements
Rank 1
answered on 04 Dec 2013, 07:02 PM

Princy

Thanks for the reply, sorry mine took so long.  I have tried what you suggested and worked it out in a solution like following:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        function OnClientNodeClicked(sender, args) {
            tv = $find("<%= TreeView1.ClientID%>");
            nodes = tv.get_selectedNodes();
            if (nodes.length > 1) {
                ....
            }
        }
    </script>
</telerik:RadScriptBlock>

Thanks again for the help!

Tags
TreeView
Asked by
nfigueroa
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
nfigueroa
Top achievements
Rank 1
Share this question
or