Is it possible to deselect RadTreeList item on OnItemClick (client side) ?

2 posts, 0 answers
  1. Alex R.
    Alex R. avatar
    8 posts
    Member since:
    Jul 2009

    Posted 10 May 2013 Link to this post

    I need to implement functionality to select/deselect item on item click event(client side).
    Single selection mode is used.

    I use

    function ItemClick(sender, eventArgs) {
      if (eventArgs.get_item().get_selected()) {
         //eventArgs.get_item().set_selected(false);
    // OR THIS ONE
         //var treelist = $find('<%=MyTreeList.ClientID %>');
         //treelist.deselectItem(eventArgs.get_item());
      }
    }

    But selection is restored every time after OnItemClick  event.

    Thx.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Aug 2013 Link to this post

    Hi Alex,

    Please take a look into the following code snippet I tried to select/deselect an item on itemclick event.

    ASPX:
    <telerik:RadTreeList ID="RadTreeList1" AutoGenerateColumns="true" Height="500px"
        runat="server" DataKeyNames="EmployeeID" ParentDataKeyNames="ReportsTo" OnNeedDataSource="RadTreeList1_NeedDataSource">
        <ClientSettings>
            <ClientEvents OnItemClick="ItemClick" />
        </ClientSettings>
    </telerik:RadTreeList>

    JS:
    <script type="text/javascript">
        function ItemClick(sender, eventArgs) {
            if (eventArgs.get_item().get_selected()) {
                eventArgs.get_item().set_selected(false); //selecting the item on item click
            }
            else {
                eventArgs.get_item().set_selected(true); //deselecting already selected row
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top