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

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

1 Answer 46 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Alex R.
Top achievements
Rank 1
Alex R. asked on 10 May 2013, 02:58 PM
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.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 30 Aug 2013, 05:34 AM
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.
Tags
TreeList
Asked by
Alex R.
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or