Reputation: 33
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>
Upvotes: 1
Views: 3962
Reputation: 515
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>");
Upvotes: 3