javascript - 如何在下拉列表中添加按钮?
问题描述
我编写了一个将 HTML 表显示到数据表中的代码。表头是动态的
<table id="tag" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
@foreach (var item in Model.HeaderModelList.Select((value, i) => new { i, value }))
{
<th id=@(item.i+1)>
@item.value.Category
<form>
<div class="filterExcel form-group">
<select id="TagCheckBox@(item.i+1)" name="TagCheckBox@(item.i+1)" asp-items="@item.value.HeaderOptions" multiple class="drp-TagCheckBoxMulti-Select">
</select>
</div>
</form>
</th>
}
<th id="@(Model.HeaderModelList.Count()+1)">Simulation Name
<span class="filterExcel">
<select id="SmilulationCheckBox" name="SmilulationCheckBox" asp-items="@Model.Simulation" multiple class="drp-TagCheckBoxMulti-Select">
</select>
</span>
</th>
<th id="@(Model.HeaderModelList.Count()+2)">
Patient Name
<span class="filterExcel">
<select id="PatientCheckBox" name="PatientCheckBox" asp-items="@Model.PatientName" multiple class="drp-TagCheckBoxMulti-Select">
</select>
</span>
</th>
</tr>
</thead>
</table>
我的jQuery代码是
$("#tag").DataTable({
"aLengthMenu": [[10, 25, 50, 75, -1], [10, 25, 50, 75, "All"]],
"iDisplayLength": 10,
serverSide: true,
processing: true,
stateSave: true,
search: true,
ajax: {
type: 'POST',
dataType: 'json',
url: 'GetFilteredPatientTags',
dataSrc: function (d) {
var values = [];
for (var i = 0; i < d.data.length; i++) {
var result = Object.values(d.data[i]);
values.push(result);
}
return values;
}
}
});
$(".filterExcel").click(function (e) {
e.stopPropagation();
})
$('.drp-TagCheckBoxMulti-Select').multipleSelect({
placeholder: 'Select specific course',
ellipsis: true,
filter: true,
filterAcceptOnEnter: true,
animate: 'fade',
width: 20
})
$('.ms-drop').width('fit-content')
多选用于过滤excel中的列
我的输出看起来像:
现在我需要在该下拉列表中添加一个选择按钮,用于过滤数据表中的相应数据。我怎样才能做到这一点?
解决方案
推荐阅读
- javascript - 无法在本地画布上绘制远程文件
- javascript - 将 $(document.body).css() 输出与字符串进行比较
- java - 在 HashSet 中添加元素
- c# - 我的船有一个错误,它不想出现在我的游戏中,我不知道为什么
- php - 当前文件夹之外的文件夹的路径
- java - 在扫描仪中使用分隔符;忽略空格和换行
- swift - 异步调用后更新 UITableView 的 numberOfRowsInSection
- excel - SUMIF、SUMIFS 还是?
- angular - 在模板中更新我的日期对象失败
- java - 启用jmx远程连接后无法重启tomcat