First of all its not about filtering(searching) of drop-down.
I am using Datatables : where one of my column has drop-down , i want when i change or select any option from it ... its should pass to it resp value
$(document).ready(function () {
dt = $('#example').DataTable({
"pagingType": "full_numbers",
"scrollY": "440px",
"scrollX": "100%",
"scrollCollapse": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/server_processing.php",
"deferRender": true,
"aoColumns": [{
className: "center",
"class": "details-control",
"orderable": false,
"data": null,
"defaultContent": "",
},
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
{ className: "center", },
],
"columnDefs": [{
"aTargets": [7],
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).css('text-align', 'center');
},
"mData": null,
"mRender": function (data, type, full) {
return '<td><select id="dynamic_select" name="dynamic_select">
\
<option id="0" value="">Select</option/>
\
<option id="1" value="test.php">1</option/>
\
<option id="2" value="test2.php">13</option/>
\
<option id="31" value="test3.php">12</option/>
\
</select></td>';
}
}]
});
$('select[name=dynamic_select]').on('change', function () {
var attvalue = $(this).children(":selected").attr("id");
var mainval = $(this).val();
var url = mainval;
if ($(this).children(":selected").attr("id") == 0) {
} else if ($(this).children(":selected").attr("id") == 1) {
window.open(url, "_self");
} else {
window.open(url, "_self");
}
return false;
});
});
below is my HTML
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
<th></th>
</tr>
</tfoot>
</table>
All is working fine ... just on change of select value .. i need it should go to resp. Url with its resp. id
Also can i define each row a unique id ( or my database primary id ) ?
Note : if i put above jquery in my simple PHP then its working .. but don't know why its not working in data-tables
Please help me