Drop Down in Table Column
Drop Down in Table Column
Hi,
I know this has been discussed many times here but I still can't find the answer I need.
I can get the column in question to hide/show through jQuery so I know I am targeting the correct column but the transformation to a drop down never happens.
Please tell me what I am missing?
'''
$(document).ready(function () {
timesheet = $('#timesheet').DataTable({
responsive: {
details: {
renderer: function (api, rowIdx, columns) {
var data = $.map(columns, function (col, i) {
return col.hidden ?
'<tr data-dt-row="' + col.rowIndex + '" data - dt - column="' + col.columnIndex + '" > ' +
'<td>' + col.title + ':' + '</td> ' +
'<td>' + col.data + '</td>' +
'</tr>' :
'';
}).join('');
return data ?
$('<table/>').append(data) :
false;
}
}
},
columnDefs: [
{
targets: 0,
orderable: false,
searchable: false,
checkboxes: true
},
{
targets: 5,
visible: false
},
{
targets: 6,
searchable: false,
renderer: function (d, t, r) {
var $select = $("<select></select>", {
"id": r[0] + "start",
"value": d
});
$.each(timesheet, function (k, v) {
var $option = $("<option></option>", {
"text": v,
"value": v
});
if (d === v) {
$option.attr("selected", "selected")
}
$select.append($option);
});
return $select.prop("outerHTML");
}
}
],
order: [
[1, 'asc']
]
});
});
'''
Replies
nothing immediately stands out as an issue. For help debugging please post a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin