My DT whic is works fine:
$('#versions').DataTable({
searching: false,
responsive: true,
processing: true,
ajax: {
url: 'GetData',
dataSrc (data) {
return data;
},
complete (jqXHR, textStatus) {
versions.clearError();
if (textStatus === 'success') {
}
else {
versions.showError(`${jqXHR.statusText}: ${jqXHR.responseText}`);
}
}
},
columns: [
{
data: 'AgentVersion'
},
{
data: null,
render: this.renderButtons,
orderable: false
}
],
createdRow(row, data, index) {
let rowJQ = $(row);
let editButton = rowJQ.find("button.edit");
editButton.on('click', (e) => {
versions.showEditDialog(data['AgentVersionsID'], data['AgentVersion']);
return false;
});
let deleteButton = rowJQ.find("button.delete");
deleteButton.click((e) => {
versions.showDeleteDialog(data['AgentVersionsID'], data['AgentVersion']);
return false;
});
},
});
I have method:
renderButtons(data, type, row) {
console.log(`ROW: ${JSON.stringify(row)}`);
if (type === "display") {
return `<span class='buttons'>
<button id="edit-action" class="mdl-button mdl-js-button mdl-button--icon mdl-button--colored mdl-js-ripple-effect edit onclick="editRow(${JSON.stringify(row)})" title='Edit record'>
<i class="material-icons">edit</i>
</button>
<button type="button" id="delete-action" class="mdl-button mdl-js-button mdl-button--icon mdl-button--colored mdl-js-ripple-effect delete onclick="deleteRow(${JSON.stringify(row)})" title='Delete record'>
<i class="material-icons">delete</i>
</button>`;
}
return data;
}
For rendering buttons in datatable, also i have deleteRow method, for now i just check if i get the value
deleteRow(row) {
console.log(`${JSON.stringify(row)}`);
}
And specific button, for deliting from dialog window:
let deleteDialog = $('#delete-dialog');
let deleteButton = deleteDialog.find('.mdl-button.action');
deleteButton.on('click', (e) => {
e.preventDefault();
versions.deleteRow();
return false;
});
Question is why i can't get this (row) from delete button in my deleteRow method? Can you please help me?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…