1

is there anyway to exclude a column in a table? i have a table with options in them for every row i want to exclude during print process.

 <table class="table table-hover table-bordered" style = "position : relative;    left : 0px; top : 0px; width : 100%; height : 10%" id = "tableitems">
 <thead>
        <th><center>ID</center> </th>
        <th><center>Item Name</center> </th>
        <th><center>Brand</center> </th>
        <th><center>Initial Price</center> </th>
        <th><center>Sales Price</center> </th>
        <th><center>Quantity</center> </th>
        <th><center>Dealer</center> </th>
        <th><center>Edit</center> </th>
        <th><center>Order</center> </th>
        <th><center>Defective</center> </th>
   </tr>
</thead>
<tbody>
    <?php
    foreach($rows as $row){
        if($row["Quantity"] < 10){
            print "<tr style = 'background-color : crimson; color : black' >";
        }else if($row["Quantity"] < 20) {
            print "<tr style = 'background-color : yellow; color : black' >";
        }else{
        }
print "<td>" . $row['ID'] . "</td>";
print "<td>" . $row['ItemName'] . "</td>";
print "<td>" . $row['Brand'] . "</td>";
print "<td>" . $row['InitialPrice'] . "</td>";
print "<td>" . $row['SalesPrice'] . "</td>";
print "<td>" . $row["Quantity"] . "</td>";
print "<td>" . $row["Dealer"] . "</td>";
print "<td><a href='Update.php?id=" . $row["ID"] . "'>Edit</a></td>";
print "<td><a href = '#!' onclick='show_overlay(" . $row['ID'] . ")'>Order</a></td>";
print "<td><a href = '#!' onclick='reorder(" . $row['ID'] . ")'>Defective</a></td>";
print "</tr>";
}
?>
</tbody>

i have this print that gets the table values to problem is it also includes the options in the table is there anyway to exclude some columns to the table?

 <script>   
 function printData(){
 var divToPrint=document.getElementById("tableitems");
 newWin= window.open("");
 newWin.document.write("<center><h1>Meng and Mher</h1><p>List of Items</p> </center>");
 newWin.document.write(divToPrint.outerHTML);
 newWin.print();
 newWin.close();
 }

 $('btnprint').on('click',function(){
 printData();
 })
 </script>
4
  • what do you mean options? simplest way perhaps would be to have a rule in your print stylesheet that hides certain cells maybe Commented Feb 14, 2016 at 15:01
  • i want to exclude in the print the last 3 columns because its a link Commented Feb 14, 2016 at 15:02
  • apply a class to those last three table cells that contain the links and add a rule to your stylesheet ( assuming you have a print stylesheet ) or, in the javascript function, remove the table cells using dom methods Commented Feb 14, 2016 at 15:06
  • @RamRaider Wow man. You read my mind :) Commented Feb 14, 2016 at 15:07

1 Answer 1

3

You could add a line to print css into the new window to hide the nth-column like below

newWin.document.write("<style> td:nth-child(2){display:none;} </style>");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.