We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

double click event on listview

Hi,

I have a situation: on a listview control, i want to do, after a double click, to unselect all other options and to remain selected only the option that i choose.


I would like, when double clicking an option check box, must have the effect of selecting only this one and uncheck

every other option; is it possible?


Many thanks,

Aurelian


2 Replies

LD LeoLavanya Dhanaraj Syncfusion Team November 7, 2022 12:33 PM

Hi Aurelian,


Greetings from Syncfusion support.


The mentioned requirement can be achieved by retrieving the checked list item details using getSelectedItems and unchecking those checked list items using the uncheckItem method of the ListView component inside the dblclick HTML event. Then check the current selected list item using the checkItem method.


Check the below mentioned code snippets and sample for your reference.


Sample : https://stackblitz.com/edit/angular-egvvbz-uqzuyh?file=app.component.ts,app.component.html


[app.component.html]

<ejs-listview id="sample-list-flat" [dataSource]="data" [showCheckBox]="true" (dblclick)="onSelect($event)"></ejs-listview>

 

[app.component.ts]

onSelect(args: any) {

    var listObj = document.getElementById('sample-list-flat').ej2_instances[0];

    var currentItem = listObj.selectedItems.data;

    var selectedLists = listObj.getSelectedItems();

    for (var it = 0; it < selectedLists.data.length; it++) {

    listObj.uncheckItem(selectedLists.data[it]);

    }

    listObj.checkItem(currentItem);

}


Regards,

Leo Lavanya Dhanaraj



AU aurelian replied to LeoLavanya Dhanaraj November 10, 2022 04:09 AM

Morning Leo, 


Many thanks for your answer. I made it to solve the situation. 


Regards, 

Aurelian.


Loader.
Live Chat Icon For mobile
Up arrow icon