problem checkbox when change page of datatable!

problem checkbox when change page of datatable!

sh4h1msh4h1m Posts: 3Questions: 1Answers: 0

hello

this is my codes:

<script>
$(function () {
    $('#example1').DataTable({
      'paging'      : true,
      'lengthChange': false,
      'searching'   : true,
      'order'    : [],
      'info'        : true,
      'autoWidth'   : false,
    'bSortable' : false,
    'aTargets'  : [ 1 ],
    'lengthMenu': [100],
    })
  })
</script>


<scirpt>
function selectOrgChildRec(ctrl){



    $(ctrl).closest('tr').toggleClass('danger');
    var closeCheckbox = $(ctrl).closest('tr').find('input[type=checkbox]');
    if (closeCheckbox.prop('checked') == false) {
      closeCheckbox.prop('checked', true);
    } else {
      closeCheckbox.prop('checked', false);
    }
}
</script>


echo '<tr onclick="selectOrgChildRec(this)">
                <td>' . $row['name'] . '</td>
                <td>' . $row['scientific'] . '</td>
                <td>' . $row['concentration'] . '</td>
                <td>' . $row['dosageform'] . '</td>
                <td><b>Barcode:</b> ' . $row['barcode'] . '<br>
                    <b>Notes:</b> ' . $row['notes'] . '<br>
                    <b>Cost:</b> ' . $row['cost'] . '<br>
                    <b>Public:</b> ' . $row['totalprice'] . '<br>
                    <b>Store:</b> ' . $row['store'] . '<br></td>
                <td>' . $row['sachet'] . '</td>
                <td>' . $row['slocation'] . '</td>      
                <td>' . $row['squantity'] . '</td>
                <td><a href="drug_action.php?itemid=' . $row['id'] . '" target="_blank"> <button type="button" class="btn btn-primary">Action</button></a></td>
                <td hidden><input type="checkbox" name="action2[]" id="action2" value="' . $row['id'] . '" ></td>
                </tr>';

all its work good, but my problem when i checkbox in page number 1 and for example i checkbox two row in another page, its just post the checkboxes in current page , so what i need when i checkbox for multiple page they post all checked rows not just in the current page !

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • sh4h1msh4h1m Posts: 3Questions: 1Answers: 0

    this is my link case: https://www.blacktools.io/shahimpanel/drugs/test_case.php

    problem: try to select checkbox in multiple pages, its just post the checkboxes in current page , so what i need when i checkbox for multiple page they post all checked rows not just in the current page !

  • sh4h1msh4h1m Posts: 3Questions: 1Answers: 0

    dont forget to click on button (Add purchases cart) after select checkbox, its just post the checkboxes in current page ! i need when i checkbox for multiple page they post all checked rows not just in the current page !

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I'm not seeing multiple pages - there is just a single scrolling page,

    Colin

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    See if this thread and the referenced thread helps. Basically you need to use Datatables API's to get the checkboxes on other pages as those pages aren't in the DOM.

    Kevin

Sign In or Register to comment.