i am trying to generate table using Jquery.Datatable , the table generated but without rendering the data , When the developer tools are opened the regular error appear although the jquery & datatable references added to the page in order , so any help here
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/jquery.dataTables.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Content/jquery.dataTables.js"></script>
<table id="datatableId" data-url="@Url.Action("Index","Home")" cellspacing="0" width="100%" class="table table-responsive table-bordered table-striped">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Data</th>
<th>Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
var datatable = {
table: null,
initializedDataTable: function () {
var $tablea = $(".table-striped");
datatable.table = $tablea.DataTable({
processing: true,
serverSide: true,
"alengthMenu": [[10, 20, 30, 40, 50], [10, 20, 30, 40, 50]],
ajax: {
url: $tablea.prop("data-url"),
type: "POST"
},
"columns": [{ "data": "FirstName" },
{ "data": "LasttName" },
{ "data": "Gender" }],
"columnDefs": [
{
"render": function (data, type, row) {
var inner = '<div class="btn-group">' +
'<button type="button" class="btn btn-secondary dropdwon-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
'Actions' +
'</button>' +
'<div class="dropdown-menu">' +
'<a href="#" class="drop-down-item btn btn-default edit" data-id="' + row.id + '" >Edit</a>' +
'<a href="#" class="drop-down-item btn btn-default delete" data-id="' + row.id + '" >delete</a>' +
'</div>' +
'</div>';
return inner;
},
"targets": -1
}
],
"pagingType": "full_numbers"
});
datatable.table.on('draw', function () {
$('button[data-type="delete"]').click(function () {
var $button = $(this);
});
$('button[data-type="Edit"').click(function () {
});
});
},
getData: function () {
if (datatable.table == null) {
datatable.initializedDataTable();
} else {
datatable.table.ajax.reload();
}
}
}
$(document).ready(function () {
datatable.getData();
});
</script>