*我的小提琴:http://jsfiddle.net/6e9r2js1/
这是某人的参考工作链接:http://jsfiddle.net/8c96qx2z/
这是某人的参考工作链接:http://jsfiddle.net/a3o3yqkw/
这是我的密码:
<table id="tabledetail">
<thead>
<tr>
<th>S.#</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><input type="text" id="name_1" name="myName[]" value="Ben"></td>
<td>
<select class="form-control" id="type_1" name="myType[]">
<option value="0" selected>No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td>2</td>
<td><input type="text" id="name_2" name="myName[]" value="Dan"></td>
<td>
<select class="form-control" id="type_2" name="myType[]">
<option value="0">No</option>
<option value="1" selected>Yes</option>
</select>
</td>
</tr>
</tbody>
</table>
<script>
var table = $('#tabledetail').DataTable({
'orderCellsTop': true,
'fixedHeader' : true,
'paging' : true,
'lengthChange' : true,
'searching' : true,
'ordering' : true,
'info' : true,
'autoWidth' : true,
'columnDefs' : [{ "type": "html-input", "targets": ['_all'] }]
});
</script>在类型上没有搜索..。
发布于 2019-10-16 13:31:48
我从这个堆叠溢出的答案中找到了一个小提琴url:https://stackoverflow.com/a/27860934/540195
我更新了小提琴(http://jsfiddle.net/s2gbafuz/),现在它运转良好,
您可以检查分叉工作小提琴链接: http://jsfiddle.net/amitmondal/zc5a3eox/1/
$.fn.dataTableExt.ofnSearch['html-input'] = function(value) {
return $(value).val();
};
var table = $("#example").DataTable({
columnDefs: [
{ "type": "html-input", "targets": [1, 2, 3] }
]
});
$("#example td input").on('change', function() {
var $td = $(this).parent();
$td.find('input').attr('value', this.value);
table.cell($td).invalidate().draw();
});
$("#example td select").on('change', function() {
var $td = $(this).parent();
var value = this.value;
$td.find('option').each(function(i, o) {
$(o).removeAttr('selected');
if ($(o).val() == value) {
$(o).attr('selected', true);
$(o).prop('selected', true);
}
})
table.cell($td).invalidate().draw();
});
,如果您需要进一步的帮助,请随时通知我。
https://stackoverflow.com/questions/58413435
复制相似问题