Fixed header in Editor
Fixed header in Editor
safavia
Posts: 36Questions: 14Answers: 0
Hello pals,
I modified the following editor code to add the fixed header feature to it. Now the fixed header feature works beautifully, but the editor's inline editing feature stopped to work! I would appreciate it if you could help me to fix the inline editing feature with keeping the fixed header feature.
Here is the code:
var editor;
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
ajax: "/api/historylog",
table: "#example",
fields: [{
label: "Comments:",
name: "Comments"
}]
});
// Activate an inline edit on click of a table cell
$('#example').on('click', 'tbody td:not(:first-child)', function (e) {
editor.inline(this, {
buttons: { label: '>', fn: function () { this.submit(); } }
});
});
editor = $('#example').DataTable({
responsive: true,
aLengthMenu: [
[500, 1000, -1],
[500, 1000, "All"]
],
dom: "Bfrtip",
ajax: "/api/historylog",
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "TableName" },
{ data: "ObjectName" },
{ data: "ColumnName" },
{ data: "OldValue", render: $.fn.dataTable.render.number(',', '.', 2, '') },
{ data: "NewValue", render: $.fn.dataTable.render.number(',', '.', 2, '') },
{ data: "UpdatedBy" },
{ data: "UpdatedOn" },
{ data: "Comments" }
],
order: [1, 'asc'],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [
{ extend: "edit", editor: editor },
'excel']}
);
new $.fn.dataTable.FixedHeader( editor );
});
Cheers,
Alan
This discussion has been closed.
Answers
Sorry guys for the false alarm! Problem solved. The fix is to add:
fixedHeader: true
Cheers,
Al