$(document).ready(function () {
var documentEditor;
var notesEditor;
/* Documents Table */
documentEditor = new $.fn.dataTable.Editor({
ajax: {
create: '/Home/NewDocumentData',
edit: {
type: 'PUT',
url: '/Home/EditDocumentData'
},
remove: {
type: 'DELETE',
url: '/Home/DeleteDocumentData'
}
},
idSrc: 'id',
table: "#otherDocsTable",
fields: [{
label: "Type:",
name: "type"
}, {
label: "Document or Drawing:",
name: "documentOrDrawing"
}, {
label: "Value:",
name: "value"
}
]
});
// Activate an inline edit on click of a table cell
$('#otherDocsTable').on('click', 'tbody td.row-edit', function (e) {
documentEditor.inline(table.cells(this.parentNode, '*').nodes(), {
submitTrigger: -2,
submitHtml: ''
});
});
// Delete row
$('#otherDocsTable').on('click', 'tbody td.row-remove', function (e) {
documentEditor.remove(this.parentNode, {
title: 'Delete record',
message: 'Are you sure you wish to delete this record?',
buttons: 'Delete'
});
});
var table = $('#otherDocsTable').DataTable({
dom: "Bfrtip",
ajax: {
"type": "GET",
"url": "/Home/GetOtherDocumentData",
"contentType": "application/json; charset=utf-8",
"dataType": "json"
},
info: false,
columns: [
{ "data": 'type' },
{ "data": 'documentOrDrawing' },
{ "data": 'value' },
{
data: null,
defaultContent: '',
className: 'row-edit dt-center',
orderable: false
},
{
data: null,
defaultContent: '',
className: 'row-remove dt-center',
orderable: false
},
],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [{
extend: "createInline",
editor: documentEditor,
formOptions: {
submitTrigger: -2,
submitHtml: ''
}
}]
});
/* Notes Table */
notesEditor = new $.fn.dataTable.Editor({
ajax: {
create: '/Home/NewNotesData',
edit: {
type: 'PUT',
url: '/Home/EditNotesData'
},
remove: {
type: 'DELETE',
url: '/Home/DeleteNotesData'
}
},
idSrc: 'id',
table: "#notesTable",
fields: [{
label: "Type:",
name: "type"
}, {
label: "Note File:",
name: "noteFile"
}, {
label: "Value:",
name: "value"
}
]
});
// Activate an inline edit on click of a table cell
$('#notesTable').on('click', 'tbody td.row-edit', function (e) {
notesEditor.inline(table.cells(this.parentNode, '*').nodes(), {
submitTrigger: -2,
submitHtml: ''
});
});
// Delete row
$('#notesTable').on('click', 'tbody td.row-remove', function (e) {
notesEditor.remove(this.parentNode, {
title: 'Delete record',
message: 'Are you sure you wish to delete this record?',
buttons: 'Delete'
});
});
var table = $('#notesTable').DataTable({
dom: "Bfrtip",
ajax: {
"type": "GET",
"url": "/Home/GetNotesData",
"contentType": "application/json; charset=utf-8",
"dataType": "json"
},
info: false,
columns: [
{ "data": 'type' },
{ "data": 'noteFile' },
{ "data": 'value' },
{
data: null,
defaultContent: '',
className: 'row-edit dt-center',
orderable: false
},
{
data: null,
defaultContent: '',
className: 'row-remove dt-center',
orderable: false
},
],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [{
extend: "createInline",
editor: notesEditor,
formOptions: {
submitTrigger: -2,
submitHtml: ''
}
}]
});
});