mercredi 19 août 2015

Add Checkbox to datatables JQuery service side

I'm server side I want to add a checkbox who returns true or false when the checkbox is checked or not. But I don't know how to add the event on change to my checkbox in the table and send the Boolean to my data. And I want to set the checkbox next to the global search.

HTML

<table id="searchlog" class="table table-striped table-bordered" cellspacing="0" width="100%">Case Sensitive :
    <input type='checkbox' id='idCaseInsensitive' />
    <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;
        }
    });
});

Could you help me to do that please?




Aucun commentaire:

Enregistrer un commentaire