将复选框添加到数据表 JQuery 服务端

Add Checkbox to datatables JQuery service side

我是服务器端我想添加一个复选框,当复选框被选中时 returns true 或 false。但我不知道如何将更改事件添加到 table 中的复选框并将布尔值发送到我的数据。我想设置全局搜索旁边的复选框。

HTML

<table id="searchlog" class="table table-striped table-bordered" cellspacing="0" width="100%">Case Sensitive :
    <input type='checkbox' id='idCaseSensitive' />
    <thead>
        <tr>
            <th>COL1</th>
            <th>COL2</th>
            <th>COL3</th>
            <th>COL4</th>
            <th>COL5</th>
            <th>COL6</th>
            <th>COL7</th>
            <th>COL8</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>

JQUERY

$(document).ready(function () {
    $('#searchlog').DataTable({
        serverSide: true,
        aaSorting: [
            [1, 'desc']
        ],
        ajax: {
            url: '/mypath/...',
            method: 'POST',
            data: {
                caseSensitive: true // I want the checkbox's return on this parameter
            }
        }
    });
    $('#idCaseSensitive').change(function (data) {
        if (this.checked) {
            return true;
        } else {
            return false;
        }
    });
});

你能帮我做一下吗?

$(document).ready(function () {
var flag=false;    
$('#idCaseSensitive').change(function (data) {
            if ($(this).attr("checked")==true) {
                flag=true;
            } else {
                flag=false;
            }
        });
    $('#searchlog').DataTable({
        serverSide: true,
        aaSorting: [
            [1, 'desc']
        ],
        ajax: {
            url: '/mypath/...',
            method: 'POST',
            data: {
                caseSensitive: flag; // I want the checkbox's return on this parameter
            }
        }
    });

});

我用 returns 标志变量的函数解决了我的问题,我在数据 caseSensitive 中使用它。