JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Table › Remove table rows › Reply To: Remove table rows
Hi Johnny,
Yes the functionality you want to achieved can be done relatively simply like in the code snippet below.
The following will remove the specific row based on the ‘id’.
In your JS file :
const table = document.getElementById(‘table’);
let userId = 0; // for example
table.selected=[userId] //selecting the userId row
document.getElementById(‘remove’).onclick = function () {
if (table.dataSource.length > 0) {
table.dataSource.removeAt(userId);
}
};
And in your HTML:
<div class=”option”><smart-button id=”remove”>Remove</smart-button></div>
<smart-table id=”table” selection> </smart-table>
Please, do not hesitate to contact us if you have any additional questions.
Best regards,
Yavor Dashev
Smart UI Team
https://www.htmlelements.com/