Hi Mahesh,
We have reviewed your query and understand your requirement
to select and unselect all items within the ListView component. To
address this, we recommend enabling checkboxes for the ListView items.
Additionally, we have integrated two Buttons, one for checking and one
for unchecking, and bound “click” events to these buttons.
When you click the "Check" button, you will
notice that all ListView items are selected. We have achieved this
functionality using the "checkAllItems"
method. Similarly, when clicking the "Uncheck" button, all
items will be unchecked, and this is accomplished using the "uncheckAllItems"
method.
Refer to the below code snippet for further reference.
|
[Index.cshtml]
....
<div id="flat-list">
<h4>Flat List</h4>
<!-- ListView element -->
<ejs-listview enable="true" id="listview" dataSource="data" showCheckBox=true>
</ejs-listview>
</div>
<ejs-button id="checkbtn" content="Check"></ejs-button>
<br />
<ejs-button id="uncheckbtn" content="UnCheck"></ejs-button>
<script>
document.getElementById('checkbtn').addEventListener('click', () => {
document.getElementsByClassName('e-listview')[0].ej2_instances[0].checkAllItems();
});
document.getElementById('uncheckbtn').addEventListener('click', () => {
document.getElementsByClassName('e-listview')[0].ej2_instances[0].uncheckAllItems();
});
</script>
|
Check out the attached sample and get back to us if you need
any further assistance.
Regards,
Suresh.
Attachment:
CoreListView_Sample_1dc9475b.zip