Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
76
rated 0 times [  80] [ 4]  / answers: 1 / hits: 60386  / 8 Years ago, wed, march 16, 2016, 12:00:00

I need to make dropdown as column in DataTable jQuery it is lookinng like as below right now Datatable



And I want it like the below image
enter



and the code which I use is



<table id=example class=hover row-border dataTable role=grid width=100%>
<thead class=dataTableHeader>
<tr>
<th>Days</th>
<th>Start Time</th>
<th>End Time</th>
</tr>
</thead>
</table>

$(document).ready(function () {
$('#example').DataTable({
aaData: OrganizationData.OrganizationPreference.ScheduleDaysCol,
columns: [
{data: DayName},
{data: StartDateHour},
{data: EndDateHour}

],
paging: false,
ordering: false,
info: false,
filter: false
});
});

More From » jquery

 Answers
28

Another way would be to use the render method:



        render: function(d,t,r){
var $select = $(<select></select>, {
id: r[0]+start,
value: d
});
$.each(times, 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);
}


Working example.


[#62923] Sunday, March 13, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
xiomara

Total Points: 378
Total Questions: 90
Total Answers: 104

Location: Guernsey
Member since Thu, Oct 7, 2021
3 Years ago
;