【问题标题】:DataTables inline editing, how to display the checkbox to checked when the data value is trueDataTables内联编辑,当数据值为true时如何显示复选框以选中
【发布时间】:2021-07-27 03:55:26
【问题描述】:

我在我的 ASP MVC Net Core 3.1 项目中使用 DataTables 1.10.22, 我有一个内联复选框,当数据值为真时如何显示要选中的复选框? 所以,回到我下面的代码,filtered_ds.is_supervisor 将是真或假,我希望在filtered_ds.is_supervisor 为真时检查自动复选框,如何做到这一点?

 {
    orderable: false,
    data: filtered_ds.is_supervisor,
    render: function (data, type, row, meta) {
    var idx = meta.row;

    if (type === 'display') 
    {
       return `<input type="checkbox" class="editor-is_supervisor" onclick="myfunc(this)" 
       id="${idx} " + (data == true ? 'checked':'') />`;
    }
    return data;
},
className: 'text-center align-middle'

【问题讨论】:

    标签: asp.net-core datatables


    【解决方案1】:

    你可以尝试使用:

        if (type === 'display')
        {
            if (filtered_ds.is_supervisor)
            {
                return "<input type='checkbox' class='editor-is_supervisor' onclick='myfunc(this)'  id='" + idx + "' checked />";
            } else
            {
                return "<input type='checkbox' class='editor-is_supervisor' onclick='myfunc(this)'  id='" + idx + "' />";
            }
                                       
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多