Recursive selection children only

3 posts, 0 answers
  1. miro mrazik
    miro mrazik avatar
    8 posts
    Member since:
    Aug 2009

    Posted 02 Aug 2012 Link to this post


    I have a problem with recursive selection. Treelist selects recursively whole branch of selected node (all its ancestors and descendants). This behavior is pretty "unconfortable" for me. If my nodes are folders and files and I select a subfolder and I want to delete it with it contents for example then I cerainly don't want to delete its parent folder (or any of its ancestors) so I would like to ask if there is any way how to make treelist to recursively select only descendant nodes of selected item.

    Thanks in advance
  2. Tsvetina
    Tsvetina avatar
    1862 posts

    Posted 07 Aug 2012 Link to this post

    Hello Miro,

    Instead of recursive selection, you can manually select the children of a given item.
    <ClientSettings Selecting-AllowItemSelection="true">
        <ClientEvents OnItemSelected="ItemSelected" OnItemDeselected="ItemDeselected" />

    <script type="text/javascript">
        function ItemSelected(sender, args) {
            var item = args.get_item();
            var childItems = item.get_childItems();
            for (var i = 0; i < childItems.length; i++) {
        function ItemDeselected(sender, args) {
            var item = args.get_item();
            var childItems = item.get_childItems();
            for (var i = 0; i < childItems.length; i++) {

    However, this can only be done for already expanded items. Non-visible children will not be selected, unless you extend the custom logic to check for not selected children of an item after it is expanded.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
  4. Priya
    Priya avatar
    10 posts
    Member since:
    Dec 2012

    Posted 25 Dec 2012 Link to this post

    Hi ,
    Thanks for your code, it works when the nodes are already expanded i.e. parent and child all are visible, but it does not work when the view is collapsed (at initial load). evn if I select the parent and expand the node the children are not selected and this is because children are not created at initial load and they are created when we expand the node for the first time.
    Please let me know if you have any solution for this. Thanks in advance.
Back to Top