如何使用检查和X渲染jQuery DataTable Boolean列?
我想在两个布尔列上使用以下 columnDef 来显示 true 的检查和 false 的 x 的检查。但是,列上没有显示任何内容:
{
targets: [5, 6],
render: function (data, type, row) {
return (data === true) ? '<span class="glyphicon glyphicon-ok txt-green"></span>' : '<span class="glyphicon glyphicon-remove txt-red"></span>';
}
}
以下内容确实有效,但很难看到正确值的复选标记。我更喜欢 glyphicon 选项:
{
targets: [5, 6],
render: function (data, type, full, meta) {
return data ? '<input type="checkbox" disabled checked/>' : '<input type="checkbox" disabled />';
}
}
I would like to use the following columnDef on two boolean columns to display a check for true and x for false. However, nothing gets displayed on the columns:
{
targets: [5, 6],
render: function (data, type, row) {
return (data === true) ? '<span class="glyphicon glyphicon-ok txt-green"></span>' : '<span class="glyphicon glyphicon-remove txt-red"></span>';
}
}
The following does work, but it is difficult to see the checkmarks for values that are true. I prefer the glyphicon option:
{
targets: [5, 6],
render: function (data, type, full, meta) {
return data ? '<input type="checkbox" disabled checked/>' : '<input type="checkbox" disabled />';
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字形示例不起作用,因为它们不再在Bootstrap 4及更高版本中得到支持。
以下是我使用fontawesome图标的解决方案:
The glyphicons example was not working because they are no longer supported in Bootstrap 4 and above.
The following is my solution using fontawesome icons: