How to programatically de-select a particular node in ListView

6 posts, 1 answers
  1. Abhishek
    Abhishek avatar
    16 posts
    Member since:
    Apr 2011

    Posted 27 Sep 2014 Link to this post

    Hi,

     We need to programatically de-select a particular node in the ListView control. Listview has option - selectable: "multiple". We don't want to use clearSelection() as it will remove selection for all the nodes.

     Please let me know how we can achieve this.

    Thanks a lot.
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 29 Sep 2014 Link to this post

    Hello Abhishek,


    In the current case you should use the select() method and select all required nodes without the one that should be deselected.

    Let me know if this was the information that you were looking for.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Abhishek
    Abhishek avatar
    16 posts
    Member since:
    Apr 2011

    Posted 29 Sep 2014 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

     I tried your suggestion but could not achieve the item de-selection.
    This is the code I tried - 

    var remainingElementsToSelect = listView.select().not(itemToDeSelect);
    listView.select(remainingElementsToSelect);

    But still the 'itemToDeSelect' remains selected. 

    Thanks in advance.







  5. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 30 Sep 2014 Link to this post

    Hi Abhishek,


    Please excuse me for the inconvenience. I missed the fact that the select() method does not override the selection, but only adds to the existing one. I would suggest to clear the current selection, before applying the new one.
    E.g.
    var remainingElementsToSelect = listView.select().not(itemToDeSelect);
    listView.clearSelection();
    listView.select(remainingElementsToSelect);

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Abhishek
    Abhishek avatar
    16 posts
    Member since:
    Apr 2011

    Posted 30 Sep 2014 in reply to Dimiter Madjarov Link to this post

    Thanks Dimiter. It solved the issue successfully!.

    Thanks a lot.
  7. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 01 Oct 2014 Link to this post

    Hello Abhishek,


    I am glad the solution resolved the issue.

    Have a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready