Select multiple (but not the node parent)

4 posts, 1 answers
  1. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 13 Jun Link to this post

    Hi,

    Lets's say I have a TreeListView as such:

    Group #1

         Item 1-1

         Item 1-2

    Group #2

         Item 2-1

         Item 2-2

     

    I need the user to be able to select one or both items under a Group - but NOT the group itself (there's reasons for it, that I don't need to get into).

    How would I do that ?

     

    Barry

  2. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 13 Jun in reply to Barry Link to this post

    As seen in the attached photo, with SelectionMode="Multiple" turned on, it turns into a huge mess. We need it so only the child nodes are selectable, and the group header rows are not.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 16 Jun Link to this post

    Hi Barry,

    For achieving this requirement, you can benefit from the SelectionChanging event of RadTreeListView. Through the AddedItems property of the event arguments you should be able to determine whether a parent or a child node has been selected. If a child node has been selected you can set the boolean Cancel property of the event arguments to True, thus disable the selection. Please take a look at the code snippet below.
    private void treeList_SelectionChanging(object sender,
        SelectionChangingEventArgs e)
    {
        if (e.AddedItems[0] is Club)
        {
            e.Cancel = true;
        }
    }

    I hope this helps.

    All the best,
    Stefan X1
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 16 Jun in reply to Stefan X1 Link to this post

    That worked great (and of course changing "Club" to my own object).

    Thanks...Barry

    P.S. please take a look at: http://www.telerik.com/forums/sorting-on-onwindowloaded-collapses-all-groups-(using-isolatedstorage)

    :-)

Back to Top