Skip to content

Commit 1341961

Browse files
Added custom column tag binding (#3)
1 parent 4800231 commit 1341961

File tree

1 file changed

+18
-3
lines changed
  • src/jQueryDatatableServerSideNetCore/wwwroot/js

1 file changed

+18
-3
lines changed

src/jQueryDatatableServerSideNetCore/wwwroot/js/app.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
$(document).ready(function () {
1+
var table;
2+
3+
$(document).ready(function () {
24
$.fn.dataTable.moment("DD/MM/YYYY HH:mm:ss");
35
$.fn.dataTable.moment("DD/MM/YYYY");
46

5-
$("#test-registers").DataTable({
7+
table = $("#test-registers").DataTable({
68
// Design Assets
79
stateSave: true,
810
autoWidth: true,
@@ -62,7 +64,13 @@
6264
return data;
6365
}
6466
},
65-
{ targets: "date-type", type: "date-eu" }
67+
{ targets: "date-type", type: "date-eu" },
68+
{
69+
targets: 10,
70+
data: null,
71+
defaultContent: "<a class='btn btn-link' role='button' href='#' onclick='edit(this)'>Edit</a>",
72+
orderable: false
73+
},
6674
]
6775
});
6876
});
@@ -74,4 +82,11 @@ function strtrunc(str, num) {
7482
else {
7583
return str;
7684
}
85+
}
86+
87+
function edit(rowContext) {
88+
if (table) {
89+
var data = table.row($(rowContext).parents("tr")).data();
90+
alert("Example showing row edit with id: " + data["id"] + ", name: " + data["name"]);
91+
}
7792
}

0 commit comments

Comments
 (0)