Hi team i have a datatable and i am loading the datatable using ajax query
My query is as follows
JavaScript
function fetchIndex() {
$(document).ready(function () {
$('#example thead tr').clone(true).addClass('filters').appendTo('#example thead');
$.ajax({
type: "POST",
dataType: "JSON",
rl: "/HRDashboard/Indexresult",
success: function (response) {
var table = $('#example').dataTable({
data: response,
columns: [
{ 'data': 'employeeId' },
{ 'data': 'employeeName' },
{ 'data': 'employeeAadharCardNumber' },
{ 'data': 'employeePanCardNumber' },
{ 'data': 'employeeManager' },
{ 'data': 'employeePersonalNumber' },
{ 'data': 'employeeEmail' },
{ 'data': 'employeeDesignation' },
{ 'data': 'employeeTeam' },
{ 'data': 'employeeManager' },
{ 'data': 'employeeAddress1' },
{ 'data': 'mail1Status' },
{ 'data': 'mail1SentDatetime' },
{ 'data': 'mail2Status' },
{ 'data': 'mail2Datetime' },
{ 'data': 'mail3Status' },
{ 'data': 'mail3SentDatetime' },
{ 'data': 'mail4Status' },
{ 'data': 'mail4SentDatetime' },
{
mRender: function (data, type, row) {
return ' | ';
}
},
],
autofill: true,
select: true,
responsive: true,
destroy: true,
orderCellsTop: true,
fixedHeader: true,
scrollY: true,
scrollX: true,
initComplete: function () {
var api = this.api();
// For each column
api.columns().eq(0).each(function (colIdx) {
// Set the header cell to contain the input element
var cell = $('.filters th').eq($(api.column(colIdx).header()).index());
var title = $(cell).text();
$(cell).html('');
// On every keypress in this input
$('input', $('.filters th').eq($(api.column(colIdx).header()).index()))
.off('keyup change')
.on('keyup change', function (e) {
e.stopPropagation();
// Get the search value
$(this).attr('title', $(this).val());
var regexr = '({search})'; //$(this).parents('th').find('select').val();
var cursorPosition = this.selectionStart;
// Search the column for that value
api
.column(colIdx)
.search((this.value != "") ? regexr.replace('{search}', '(((' + this.value + ')))') : "", this.value != "", this.value == "")
.draw();
$(this).focus()[0].setSelectionRange(cursorPosition, cursorPosition);
});
});
}
})
table.columns.adjust().draw();
},
error: function (error) {
console.log(response);
}
});
});
}i am able to add the snipped to show the edit button but on click i am not able to pass the employeeid of the row clicked .
I am not sure where i went wrong..
Also i need to show the following 3 action items in a same
Code
|
|How to achieve it
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsForums
Top experts
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajkiran SwainRank #165 · 14.4K reputationPosted Apr 4, 2023, 8:23 AM EDT
columns: [ { 'data': 'employeeId' }, { 'data': 'employeeName' }, { 'data': 'employeeAadharCardNumber' }, { 'data': 'employeePanCardNumber' }, { 'data': 'employeeManager' }, { 'data': 'employeePersonalNumber' }, { 'data': 'employeeEmail' }, { 'data': 'employeeDesignation' }, { 'data': 'employeeTeam' }, { 'data': 'employeeManager' }, { 'data': 'employeeAddress1' }, { 'data': 'mail1Status' }, { 'data': 'mail1SentDatetime' }, { 'data': 'mail2Status' }, { 'data': 'mail2Datetime' }, { 'data': 'mail3Status' }, { 'data': 'mail3SentDatetime' }, { 'data': 'mail4Status' }, { 'data': 'mail4SentDatetime' }, { mRender: function (data, type, row) { return ' | ' + ' | ' + ''; } }, ],