Hi Farhan,
Thanks for contacting Syncfusion support.
We can use either of the following two methods to clear/destroy the ListView Control.
- Empty the dataSource
- In this case, the listview instance is available for the element and we can render listview by updating dataSource property again.
- Destroy the control completely with destroy method.
Refer the below code snippet to empty the dataSource and destroy the widget.
|
<script>
// Empty the ListView DataSource
document.getElementById('btn').addEventListener('click', function () {
let listObj = document.getElementById('list').ej2_instances[0];
listObj.dataSource = [];
});
// Destroy the ListView
document.getElementById('element').addEventListener('click', function () {
let listObj = document.getElementById('list').ej2_instances[0];
listObj.destroy();
});
</script> |
For your convenience we have prepared a sample and attached below. Refer to the below sample link.
We recommend you to refer the below API and getting started links to know more about ListView Control.
Please let us know If you need further assistance on this.
Regards,
M. Balaji