RadListview Item Selection and Deselction

5 posts, 0 answers
  1. Ganesh
    Ganesh avatar
    11 posts
    Member since:
    Jun 2017

    Posted 16 Aug 2017 Link to this post

    Hi,

    I have implemented a RadListview with Selection mode Multiple.

    when user select an Item the Item is selecting as per the selection mode and selection Gesture which is fine.

    But now I have a scenario to some items to not select when user try to select it even selection mode is enabled, instead it should be in deselection mode. It should check the flag from Itemsource  of the listview Item and disable that Item programatically it should show a toast message like which is not selectable.

    Help me out to implement this scenario and suggest me the approaches if any.

     

    Thanks,

  2. Ganesh
    Ganesh avatar
    11 posts
    Member since:
    Jun 2017

    Posted 16 Aug 2017 Link to this post

    Hi There is an option in Xamarin Forms ListView like below to deselect the list Item

              if (e.Item == null) return;

              //Add some condition logic based on your requirement here//like ---->

               if(((ListView)sender).SelectedItem.value == "none")

                        ((ListView)sender).SelectedItem = null;

    But same option is throwing an exception with RadListView like below

                      ((RadListView)sender).SelectedItem = null;  

      It seems there is no set functionality of the RadListview SelectedItem.

    Please provide the solution or how to implement this using RadListView?

     

    Thanks,

     

  3. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    140 posts

    Posted 18 Aug 2017 Link to this post

    Hi Ganesh,

    You could use the following code snippet to clear the selected items:
    this.listView.SelectionChanged += (sender, e) => {
                    if (this.listView.SelectedItem != null)
                    {
                        if (this.listView.SelectedItems.Count() > 0)
                        {
                            this.listView.SelectedItems.Clear();
                        }
                    }
                };

    If you want to deselect specific item you could just remove it from the collection.

    Regards,
    Nikolay Demirev
    Progress Telerik
    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 Feedback Portal and vote to affect the priority of the items
  4. Craig Neblett
    Craig Neblett avatar
    8 posts
    Member since:
    Nov 2005

    Posted 30 Nov 2017 Link to this post

    This means of clearing the selection no longer seems to work using the latest version of UI with the most recent version of Xamarin.Forms. You can clear the collection and set SelectedItem to null, but the item remains visually selected in the list view. Can you provide guidance on how the selection can be cleared?
  5. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    140 posts

    Posted 05 Dec 2017 Link to this post

    Hello Craig,

    I can confirm, there is an issue clearing the selection with the code snippet I have sent is no longer working. We will investigate the issue, but meanwhile, you could workaround the issue easily using the following code snippet:

    if (this.listView.SelectedItem != null)
    {
        if (this.listView.SelectedItems.Count() > 2)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                this.listView.SelectedItems.Clear();
            });
        }
    }

    I hope this helps.

    Regards,
    Nikolay Demirev
    Progress Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top