asp.net-core - 我如何使用自定义字段而不在 DataTable 中呈现
问题描述
桌子上的一些列想要使用而不渲染它。例如,表有五列,我想在 TBODY 中定义第一列和最后一列。列 2-3-4 必须通过 DataTable 呈现
我已经尝试为该列设置 null, data:'' , type:'html' 但它们不起作用。总是给出关于第 0 行的错误。
<thead>
<tr>
<th scope="col">
#
</th>
<th scope="col">
<label class="control-label">Loc</label>
</th>
<th>
<label class="control-label">Date</label>
</th>
<th>
<label class="control-label">Per</label>
</th>
<th>
<label class="control-label">Type</label>
</th>
<th scope="col">#</th>
</tr>
</thead>
<tbody>
foreach (var item in Model)
{
<tr>
<td>
Always True
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Some partial views
</td>
</tr>
}
}
</tbody>
</table>
<script>
var table = $('#dataTable').dataTable({
"processing": true,
"serverSide": true,
"info": true,
"stateSave": true,
responsive: {
details: false
},
lengthMenu:
[
[10, 20, 50, -1], [10, 20, 50, "All"]
],
ajax: {
"url": "myUrl.json",
"type": "POST",
"contentType": 'application/json; charset=utf-8',
"dataType": 'json',
'data': function(data) {
return JSON.stringify(data);
},
"error": function(xhr, error, thrown) {
alert("error");
}
},
"columns": [
{
//this column get from TBODY,
}
{
data: 'loc',
responsivePriority: 1
},
{
data: 'date',
responsivePriority: 5
},
{
data: 'per',
responsivePriority: 3
},
{
data: 'type',
responsivePriority: 4
},
{
//This column get from TBODY because there is a partial view
}
],
rowId: "id",
"order": [[1, "asc"]],
});
</script>
解决方案
推荐阅读
- android - Admob 原生广告拦截 UI 线程
- bash - Bash - 需要检查日期记录之前和之后
- python - 从加权边缘列表创建有向加权网络图
- javascript - Angular - 将变量传递给 index.html 中的脚本
- content-management-system - hybris 智能编辑错误
- mongodb - 使用 Audit.Net.MongoDB 时的问题
- javascript - 无法将 2015,2016 字段复制到受尊重年份 2015,2016 值的值属性
- c# - Unity 场景未加载
- swift - 为什么不能符合关联类型的协议?
- c - C - 如果将包含包含在标头中,则重复符号,但如果包含在源文件中则工作正常