I need to have a button at the end of each row in my datatable and get the row values when I click on it. Please see my code below.
In my .ts
ngOnInit() {
this.getUsers();
}
getUsers() {
this.us.getUsers()
.subscribe((data: any) => {
this.users = data;
var table = $('#datatables').DataTable({
"pagingType": "full_numbers",
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
responsive: true,
data:this.users,
columns:[
{
data:"Id"
},
{
data:"FirstName"
},
{
data:"MiddleName"
},
{
data:"LastName"
},
{
data:"UserName"
},
{
data:"Email"
},
{
data:"DateAdded"
},
{
data:"IsActivated"
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search records",
}
});
})
}
In my ,html
<table id="datatables" class="table table-striped table-bordered table-hover" cellspacing="0"
width="100%" style="width:100%">
<thead>
<tr>
<th>Id</th>
<th>FirstName</th>
<th>MiddleName</th>
<th>LastName</th>
<th>UserName</th>
<th>Email </th>
<th>DateAdded</th>
<th>Activated</th>
</tr>
</thead>
</table>
Can you please help me how to this right. I can't use the *ngFor loop because it causes issues int the datatables. Thank you.