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

How to programatically de-select a particular node in ListView

5 Answers 62 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 27 Sep 2014, 11:11 AM
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.

5 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 29 Sep 2014, 10:28 AM
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!
 
0
Abhishek
Top achievements
Rank 1
answered on 29 Sep 2014, 05:19 PM
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.







0
Accepted
Dimiter Madjarov
Telerik team
answered on 30 Sep 2014, 08:10 AM
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!
 
0
Abhishek
Top achievements
Rank 1
answered on 30 Sep 2014, 02:49 PM
Thanks Dimiter. It solved the issue successfully!.

Thanks a lot.
0
Dimiter Madjarov
Telerik team
answered on 01 Oct 2014, 07:25 AM
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!
 
Tags
ListView
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Abhishek
Top achievements
Rank 1
Share this question
or