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

Select multiple (but not the node parent)

3 Answers 96 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 13 Jun 2016, 06:09 PM

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

3 Answers, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 13 Jun 2016, 08:56 PM
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.
0
Accepted
Stefan
Telerik team
answered on 16 Jun 2016, 06:52 AM
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.
0
Barry
Top achievements
Rank 1
answered on 16 Jun 2016, 01:49 PM

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)

:-)

Tags
TreeListView
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or