RadTreeListView with Checkbox, Multiple selection and not CanUserSelect

11 posts, 0 answers
  1. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 12 May 2011 Link to this post

    Hi,

    I want the user to be able to navigate through the tree and actively select one or several nodes by the use of the keboard.

    I have tried the all kinds of different options on the RadTreeListView. Added the GridViewSelectColumn, set the SelectionMode to Extended, set the CanUserSelect to false.
    When I try to navigate with the keyboard I get unexpected behaviour.

    What settings should I use?

    Best regards
    Erik

     

     

     

     

  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 12 May 2011 Link to this post

    Hi Erik,

     

    By default the end user can select only a single item since the SelectionMode property of RadTreeListView is set to Single. If you set this property to Extended you will be able to the Shift + Up / Down arrows to select multiple rows. In any other case you need to predefine the default behavior of these keyboards you may create your custom keyboard command provider, as demonstrated in the following blog post.


    Best wishes,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 12 May 2011 Link to this post

    Hi,

    To simplify the problem, only by setting the property CanUserSelect="False" I can not navigate the tree with the keyboard. The first row witch is selected by default I can expand, but no other nodes.

     

    /Erik

  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 12 May 2011 Link to this post

    Hello Erik,

     

    This behavior is by design. When you set the RadTreeListView's CanUserSelect Property to False you disable the selection to the end-user. However it is still possible the manipulate the selection programmatically as described in our online documentation. 


    Regards,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 12 May 2011 Link to this post

    Hello Erik,

     

    This behavior is by design. When you set the RadTreeListView's CanUserSelect Property to False you disable the selection to the end-user. However it is still possible to manipulate the selection programmatically as described in our online documentation. 


    Regards,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    Hi,

    Now I have written a

    CustomKeyboardCommandProvider

    but when I do

    commandsToExecute.Add(

     

    RadGridViewCommands.ExpandHierarchyItem);

     

    it expands the node that is selected and not the node that is the CurrentItem.

    Can you show me an example on how to naivigate the WPF RadTreeListView using the keyboard.

    Best regards
    Erik
  8. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 23 May 2011 Link to this post

    Hi Erik,

     

    You may use the Up / Down / Left / Right arrows to navigate in RadTreeListView. If you need to predefine the default keyboard navigation you should create your own custom keyboard command provider, as demonstrated in the following online help article. Then you can easily manipulate this behavior in an appropriate for your custom needs manner.


    Please give it a try and let me know if you have any further inqueries.  



    Best wishes,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    Hi,

    That is what I have done. It doesn’t work!

     

     

    public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)

            {

                List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();

                ObservableCollection<WarehouseItem> list = ((ObservableCollection<WarehouseItem>)this.parentGrid.ItemsSource);

                if (key == Key.Up)

                {

                    commandsToExecute.Clear();

                    commandsToExecute.Add(RadGridViewCommands.MoveUp);

                }

                else if (key == Key.Down)

                {

                    commandsToExecute.Clear();

                    commandsToExecute.Add(RadGridViewCommands.MoveDown);

                }

                else if (key == Key.Right)

                {

                    commandsToExecute.Clear();

                    commandsToExecute.Add(RadGridViewCommands.ExpandHierarchyItem);

                    commandsToExecute.Add(RadGridViewCommands.MoveRight);

                }

                else if (key == Key.Left)

                {

                    commandsToExecute.Clear();

                    commandsToExecute.Add(RadGridViewCommands.CollapseHierarchyItem);

                    commandsToExecute.Add(RadGridViewCommands.MoveLeft);

                }

                else if (key == Key.Space)

                {

                    commandsToExecute.Clear();

                    commandsToExecute.Add(RadGridViewCommands.SelectCurrentUnit);

                }

     

                return commandsToExecute;

            }

     

  10. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    I want multiple (extended) select so I changed the code for the SPACE key:

     

    else if (key == Key.Space)

    {

        commandsToExecute.Clear();

        if (parentGrid.CurrentItem != null)

        {

            if (parentGrid.SelectedItems.Contains(parentGrid.CurrentItem))

               parentGrid.SelectedItems.Remove(parentGrid.CurrentItem);

            else

                parentGrid.SelectedItems.Add(parentGrid.CurrentItem);

        }

    }

    but it only works if I press with the mouse in the checkbox first.

  11. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 23 May 2011 Link to this post

    Hi Erik,

     I have prepared sample application that enables the desired behavior. Please, have a look at the attachment and let us know if you have any further questions or issues.

    Kind regards,
    Tsvyatko
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Erik
    Erik avatar
    6 posts
    Member since:
    May 2011

    Posted 24 May 2011 Link to this post

    Thank you for the sample!
    /Erik

     

Back to Top
UI for WPF is Visual Studio 2017 Ready