我不确定如何将值从DropDown列表动态转移到jquery DataTable,当我从列表中选择一个曾经被转移的值不再出现在DropDown列表中时,但是如果我将其删除,从它出现回来的数据表。将使用数据库表中的用户填充“下拉列表”,每个用户都有自己的ID。我需要列表值不出现在视图中,后端还可以,我想可以用javascript完成,但我不确定如何。
我没有任何代码,因为我对如何制作没有丝毫的想法,我对编码还是很陌生,因此欢迎任何帮助。
最佳答案
如果我正确理解了您的问题,这很容易。
将一个类添加到您要在下拉列表中显示更改后的值的列中。例如,
//my rest code for DataTable
"columns": [
{
"render": function (data, type, row) {
return "<input type='text' class='myDropDownValue'>";
}
},
//Rest columns
在DropDown更改事件中,只需将值呈现给此类,例如波纹管,
$('#myDropDown').change(function(){
var myValue = $(this).val();
//here we can render this value to data table row
$('.myDropDownValue').html('');
$('.myDropDownValue').val(myValue);
})
而已!