Javascript 如何使用Jquery在打印数据表上设置列的数据视图
以下是我的设想: 我的DataTable具有如下视图: 但当我打印时,它显示如下: 我想在Datatable(第一张图片)中打印相同的内容。如何在jquery中实现这一点 我的javascript代码是:Javascript 如何使用Jquery在打印数据表上设置列的数据视图,javascript,jquery,Javascript,Jquery,以下是我的设想: 我的DataTable具有如下视图: 但当我打印时,它显示如下: 我想在Datatable(第一张图片)中打印相同的内容。如何在jquery中实现这一点 我的javascript代码是: $(文档).ready(函数(){ $('#示例')。数据表({ dom:'Bfrtip', 按钮:[ { 扩展:'print', 出口选择:{ 栏目:[ 0,1,2,3,4 ] } } ] } ); } ); 以下是我的html/php代码: <table class="ta
$(文档).ready(函数(){
$('#示例')。数据表({
dom:'Bfrtip',
按钮:[
{
扩展:'print',
出口选择:{
栏目:[
0,1,2,3,4
]
}
}
]
} );
} );
以下是我的html/php代码:
<table class="table table-bordered" id="example" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Location Address</th>
<th>Contact</th>
<th>Pending Docs</th>
<th>Status</th>
<th>Edit</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Location</th>
<th>Contact</th>
<th>Pending Docs</th>
<th>Status</th>
<th>Edit</th>
</tr>
</tfoot>
<tbody>
<?php
if($fetch_data->num_rows() > 0)
{
foreach($fetch_data->result() as $row)
{
/*$data["fetch_data"] = $this->main_model->fetch_data();*/
$this->load->model("main_model");
$docs= $this->main_model->docs_showing($row->cust_id);
?>
<tr>
<td><?php echo $row->business_name; ?></td>
<td><?php echo $row->business_location; ?></td>
<td><?php echo $row->cust_contact; ?></td>
<td>
<?php
if($docs->num_rows() > 0)
{
echo '<ul>';
foreach($docs->result() as $row1)
{
echo '<li>'.$row1->doc_name.'</li>';
}
echo '</ul>';
?>
</td>
<td>
<?php
echo '<ul>';
foreach($docs->result() as $row1)
{
echo '<li>'.$row1->doc_status.'</li>';
}
echo '</ul>';
}
else
{
echo "No Docs available";
}
?>
</td>
<td><a href="#" class="btn btn-primary"> Edit</td>
</tr>
<?php
}
}
else
{
?>
<?php
}
?>
</tbody>
</table>
名称
地址
接触
未决文件
地位
编辑
名称
位置
接触
未决文件
地位
编辑
编辑
我必须用javascript代码编写哪些内容来剪切打印功能专栏中的数据视图?您能在这里添加代码/更多信息吗?我已经添加了。看见
<table class="table table-bordered" id="example" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Location Address</th>
<th>Contact</th>
<th>Pending Docs</th>
<th>Status</th>
<th>Edit</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Location</th>
<th>Contact</th>
<th>Pending Docs</th>
<th>Status</th>
<th>Edit</th>
</tr>
</tfoot>
<tbody>
<?php
if($fetch_data->num_rows() > 0)
{
foreach($fetch_data->result() as $row)
{
/*$data["fetch_data"] = $this->main_model->fetch_data();*/
$this->load->model("main_model");
$docs= $this->main_model->docs_showing($row->cust_id);
?>
<tr>
<td><?php echo $row->business_name; ?></td>
<td><?php echo $row->business_location; ?></td>
<td><?php echo $row->cust_contact; ?></td>
<td>
<?php
if($docs->num_rows() > 0)
{
echo '<ul>';
foreach($docs->result() as $row1)
{
echo '<li>'.$row1->doc_name.'</li>';
}
echo '</ul>';
?>
</td>
<td>
<?php
echo '<ul>';
foreach($docs->result() as $row1)
{
echo '<li>'.$row1->doc_status.'</li>';
}
echo '</ul>';
}
else
{
echo "No Docs available";
}
?>
</td>
<td><a href="#" class="btn btn-primary"> Edit</td>
</tr>
<?php
}
}
else
{
?>
<?php
}
?>
</tbody>
</table>