table display having a column of checkboxes gets hidden when using datatable

table display having a column of checkboxes gets hidden when using datatable

rbindurbindu Posts: 4Questions: 2Answers: 0
edited December 2020 in Free community support
<form action="<?php echo URLROOT; ?>/posts" method="post">
    <button type="submit" value="Delete" name="delete_multiple_data" class="btn btn-danger float-right">Delete Multiple Items</button>
    
    <div class="space"><h1>&nbsp;</h1></div>
        <table class="display table table-striped table-bordered dt-responsive nowrap" style="width:100%">
          <thead class="thead-dark">
          <tr class="danger">
                       <tr class="danger">
                        <th scope="col">#</th>
                        <th scope="col">ID</th>
                        <th scope="col">Pack Name</th>
                        <th scope="col">Pack No</th>
                        <th scope="col">System Type</th>
                        <th scope="col">Document Type</th>
                        <th scope="col">Document No</th>
                        <th scope="col">VVReport No</th>
                        <th scope="col">ATR No</th>
                        <th scope="col">RFC No</th>
                        <th scope="col">Select</th>
                                        
                      </tr>
           </thead>
           <?php $n =0; ?>
<tbody> 

<?php foreach($data['posts'] as $post) : ?>  
<?php $n=$n+1; ?>    
  
      <tr>
      <th scope="row"><?php echo $n; ?></th>
      <td><?php echo $post->id; ?></td>
      <td><?php echo $post->pckname; ?></td>
      <td><?php echo $post->pckno; ?></td>
      <td><?php echo $post->Asystemtype; ?></td> 
      <td><?php echo $post->Adoctype; ?></td>
      <td><?php echo $post->Adocno; ?></td>
      <td><?php echo $post->Avvno; ?></td>
      <td><?php echo $post->Aatrno; ?></td>
      <td><?php echo $post->Arfcno; ?></td>
      <td><input type="checkbox" name="delete[]" value="<?php echo $post->id; ?>"></td>
      </tr>
           
  <?php endforeach; ?>
  </tbody>
        </table>
        </form>

This was displaying fine, but when i used datatable to include search feature 
<script type="text/javascript">
$(document).ready(function(){
    $("#mtab").DataTable({
        
    });
});
</script>

my checkbox disappears! i don't what to do!

Edited by Kevin:  Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    Not saying this is the problem but you do have an extra tr tag in line 7.

    There is nothing else obvious from your code snippet. For help please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Inspect the web page to see what the resulting input tag is then use that in a test case.

    Kevin

  • rbindurbindu Posts: 4Questions: 2Answers: 0

    I have identified the error it was <table class="display table table-striped table-bordered dt-responsive nowrap" style="width:100%">

    after I removed nowrap it was working fine, both my checkbox as well as search feature was visible.

    Thanks

This discussion has been closed.