Can we get and set info for current rows?

Can we get and set info for current rows?

El_MatellaEl_Matella Posts: 12Questions: 6Answers: 0

Hi, I am trying to implement a little function, in order to add a checkbox at the beginning of the rows. Everything is ok for the moment.

But then, I try to implement a new checkbox, and I would like, when I click on it, that it clicks all the checkboxes on the current page/search...

For the moment I have that, but it works only for first page. When I try to change page and click on the head checkbox, the table goes back to the first page and I don't know why...

$('#SelectAllProductsCheckbox').click(function(){
    $('.selectcheckbox').click();
});

And a row in my table looks like:

<tr role="row">
    <td class="sorting_1">
        <span>
            <input class="selectcheckbox" type="checkbox" name="selected">
        </span>
    </td>
    <td>
        <span>
            <a target="_blank" href="/app_dev.php/products/3021/edit"><i class="fa fa-edit"></i> 3021</a>
        </span>
    </td>
</tr>

thanks in advance for your help, and have a nice day!

Answers

  • El_MatellaEl_Matella Posts: 12Questions: 6Answers: 0

    My problem is solved, sorry for asking too early...

    The problem was that when I clicked on the head checkbox, the table was actually trying to sort by this column... So I just added something like:

    table = $('#Table').DataTable( {
        "ajax": {
            "url": $('#Table').data('json'),
            "dataSrc": ""
        },
        "deferRender": true,
        "order": [[1, 'desc']],
        "columns": [
            {
                "data": null,
                "orderable": false,
                "defaultContent": '<input class="selectcheckbox" type="checkbox" name="selected" />'
            },
            ...
    

    And it works like a charm :)

This discussion has been closed.