Hi Alfredo,
Greetings from Syncfusion support.
We have checked your reported query with ListView component. We suspect that your requirement is to select all list items in the ListView component, and this can be achieved using checkAllItems method of ListView.
Refer the below code snippet.
|
<button id='add' (click)='Select($event)' class="e-control e-btn e-lib e-primary">Select All</button>
<ejs-listview id='sample-list' #listview [dataSource]='data' [fields]='fields' [showCheckBox]='true' headerTitle='To Do List' showHeader='true'></ejs-listview>
Select() {
// Select all the items in ListView component.
this.listview.checkAllItems();
} |
And also, if you want to clear the selected item using ESC key. In ListView component, we have provided a unCheckAllItems method, it clears all the selected item in ListView component.
To achieve your requirement, you need to bind the keydown event and clear the selection using unCheckAllItems method.
Refer the below code snippet.
|
@HostListener('window:keydown', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
if(event.keyCode == 27){
this.listview.uncheckAllItems();
} |
Refer the sample link below.
If you want to select only the particular item, we suggest you to use selectItem method of ListView component.
Refer the below link to know more about the ListView component.
Please let us know, if you need any further assistance.
Regards,
Sowmiya.P