0

我的 ASP MVC Net Core 3.1 使用 DataTables 1.10.22 来显示和编辑数据,“活动”列是一个内联复选框,单击复选框时如何更新 DataTables 行中的数据?

<table id="datagrid" class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
       <th class="align-middle">Id</th>
       <th class="align-middle">Active</th>
    </tr>
   </thead>

('#datagrid').DataTable({
      searching: false, paging: false, info: false,
      data: data.filter(function (item) {
            return item.selected == true;
      }),
      select: {
                'style': 'multi'
              },
      columns: [
                 {
                    data: data.id,
                    className: 'text-left align-left'
                 },
                 {
                    orderable: false,
                    data: data.is_active,
                    render: function (data, type, row) {
                    if (type === 'display') {
                         return '<input type="checkbox" class="editor-                   
                                  is_active" onclick="myfunc()" >';
                         }
                         return data;
                    },
                            className: 'text-center align-middle'
                 }
               ],
              select: {
                        style: 'os',
                        selector: 'td:first-child'
              },
              rowCallback: function (row, data) {
              $('input.editor-is_active', row).prop('checked',                       
                    data.is_active == true);
                    }
                });

保存时,即使显示已选中,“Active”值仍然为“false”,为什么?

if (status == 'Valid') {
            const params = new FormData($('#form-data')[0]);

            console.log(JSON.stringify(params));

console.log 结果:

is_active: false
id: "TES001"
4

0 回答 0