I want the table heading to be displayed on each page while generating pdf using MPDF library.
$mpdf = new \Mpdf\Mpdf([
'mode'=>'utf-8',
'format' => 'A4-L'
]);
$mpdf->SetHTMLHeader("<table>
<tr>
<th>Sl No.</th>
<th>Name</th>
</tr>
");
for($i=0; $i<500;$i++){
$mpdf->WriteHTML("<tr>");
$mpdf->WriteHTML("<td>".$res[$i]["slno"]."</td>");
$mpdf->WriteHTML("<td>".$res[$i]["name"]."</td>");
$mpdf->WriteHTML("</tr>");
}
$mpdf->WriteHTML("</table>");
Just use a <thead> tag. Outside the page header.
$mpdf->WriteHTML('
<table>
<thead>
<tr>
<th>Sl No.</th>
<th>Name</th>
</tr>
<thead>
...');
https://mpdf.github.io/tables/tables.html#repeating-table-header-row-on-new-page
Related
I add <table repeat_header="0" > but it doesn't work for me. I want thead html tag only show in first page.
<table>
<thead>
<tr>
<th>#</th>
<th>First</th>
<th>Last</th>
<th>Handle</th>
</tr>
</thead>
<tbody>
....
</table>
My mpdf config is:
$mpdf = new mPDF('s');
$mpdf->SetDisplayMode('fullpage');
$file_name = $_SESSION["file_name"];
$html = $_SESSION['pdf'];
$html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
$mpdf->WriteHTML($html);
$mpdf->Output($file_name, 'F');
$mpdf->Output();
Do not use the <thead> element, use only simple table row with <th> cells.
<table>
<tr>
<th>#</th>
<th>First</th>
<th>Last</th>
<th>Handle</th>
</tr>
<tbody>
....
</table>
There is no other way to achieve this in mPDF.
vendor\mpdf\mpdf\src\Tag\THead.php
vendor\mpdf\mpdf\src\Tag\TFoot.php
$this->mpdf->tablethead = 1; to --> $this->mpdf->tablethead = 0;
$this->mpdf->tabletfoot = 1; to --> $this->mpdf->tabletfoot = 0;
I got a huge dataset with around 39 columns. Now the datatable exceeds the display area of the browser.
No problem with rows is they are listed based on pagination. Is there any wrapping property to datatables? I want to display all columns in the same browser space
My datatable columns are
<table id='datatable' class="ui celled table" style='width:100%'>
<thead>
<tr>
<th>DeviceID</th>
<th>AppID</th>
<th>IsFingerprint</th>
<th>CurrentDate</th>
<th>IsSDCard</th>
<th>NetworkType</th>
<th>TotalRAM</th>
<th>AvailInternal</th>
<th>AvailExternal</th>
<th>TotalInternal</th>
<th>TotalExternal</th>
<th>Activity</th>
<th>Package</th>
<th>AppStore</th>
<th>AppName</th>
<th>AppVersion</th>
<th>AppVersionCode</th>
<th>BatteryCharge</th>
<th>IsCharging</th>
<th>Manufacturer</th>
<th>Model</th>
<th>OSCodename</th>
<th>OSVersion</th>
<th>Product</th>
<th>Device</th>
<th>Board</th>
<th>Hardware</th>
<th>Rooted</th>
<th>Brand</th>
<th>Host</th>
<th>Time</th>
<th>User</th>
<th>ScreenResolution</th>
<th>ScreenDensity</th>
<th>ScreenSize</th>
<th>Country</th>
<th>Carrier</th>
<th>ActiveTraffic</th>
<th>AppUsage</th>
<th>Image</th>
</tr>
</thead>
<tfoot>
<tr>
<th>DeviceID</th>
<th>AppID</th>
<th>IsFingerprint</th>
<th>CurrentDate</th>
<th>IsSDCard</th>
<th>NetworkType</th>
<th>TotalRAM</th>
<th>AvailInternal</th>
<th>AvailExternal</th>
<th>TotalInternal</th>
<th>TotalExternal</th>
<th>Activity</th>
<th>Package</th>
<th>AppStore</th>
<th>AppName</th>
<th>AppVersion</th>
<th>AppVersionCode</th>
<th>BatteryCharge</th>
<th>IsCharging</th>
<th>Manufacturer</th>
<th>Model</th>
<th>OSCodename</th>
<th>OSVersion</th>
<th>Product</th>
<th>Device</th>
<th>Board</th>
<th>Hardware</th>
<th>Rooted</th>
<th>Brand</th>
<th>Host</th>
<th>Time</th>
<th>User</th>
<th>ScreenResolution</th>
<th>ScreenDensity</th>
<th>ScreenSize</th>
<th>Country</th>
<th>Carrier</th>
<th>ActiveTraffic</th>
<th>AppUsage</th>
<th>Image</th>
</tr>
</tfoot>
</table>
I use AJAX to load data from my PHP API endpoint and it works fine.
Is there any way to merge cells like AppName, AppPackage, AppVersion, AppVersionCode comes under App cell
I have used jquery datatable,
HTML Code
<table id="result_table" class="display table table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>#</th>
<th>Username</th>
<th>Activation Status</th>
<th>Recent Login</th>
<th>Total No. of login</th>
<th>Avg No. of login/day</th>
<th>Total No. of Exports</th>
<th>Total No. of access</th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th>Username</th>
<th>Activation Status</th>
<th>Recent Login</th>
<th>Total No. of login</th>
<th>Avg No. of login/day</th>
<th>Total No. of Exports</th>
<th>Total No. of access</th>
</tr>
</tfoot>
</table>
and I have to load the table data in ajax call in JSON datatype here my PHP code
while($row = mysql_fetch_array($run_query)){
$name = $row['first_name'];
$name_string = "<a edit_id='name_".trim($name)."' href='#' onClick=\"click_today('{$name}');\" data-toggle='modal' data-target='#myModal'>{$name}</a>";
//onClick=\"click_today('{$name}');\"
$result_array[] = array($row['id'], $name_string, $row['last_name'], $row['job_title'], $row['salary'],"-","-","-");
}
echo json_encode($result_array);
acutually my result is (sample output)
but i want following image output in datatable
I don't know how to implement vertical header in jquery data table I am always using horizontal thead but now I need vertical header because of needed pls share ur suggestion or solution
It is possible to make this kind of output from server side[php] only then
to assign datatable. I had also face this problem but I make way from server side
and another way is also there you change your expected format using PIVOT Table
using database
I have a bottstrap html table:
<table data-toggle="table" data-url="../../scripts/tags/s_displaytags.php" data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="TagName" data-sort-order="desc">
<thead>
<tr>
<th data-field="SerialNumber" data-sortable="true">Serial #</th>
<th data-field="TagName" data-sortable="true">Tag Name</th>
<th data-field="CreatedBy" data-sortable="true">Created By</th>
</tr>
</thead>
</table>
I'm trying to populate it using a PHP script s_displaytags.php. Currently im testing it so the code is:
<?PHP
$ArrayValue = array();
$ArrayValue['SerialNumber'] = 1;
$ArrayValue['TagName'] = 'test';
$ArrayValue['CreatedBy'] = 50;
echo json_encode($ArrayValue);
?>
My HTML page loads but the table values do not get loaded.
I'm not using any functions at the moment. It's just a plain PHP file returning one result row encoded s JSON.
so i just changed echo json_encode($ArrayValue); to echo json_encode(array($ArrayValue)); and it worked.
I have a requirement to output a table using Smarty and then have the user select a row to take them to another page.
I can display the table fine:
{html_table cols="Job Title,Salary,Sector,Location" loop=$results}
which gives:
<table border="1">
<thead>
<tr>
<th>Job Title</th>
<th>Salary</th>
<th>Sector</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dog walker</td>
<td>20000</td>
<td>None</td>
<td>London</td>
</tr>
<tr>
<td>F1 Driver</td>
<td>10000000</td>
<td>Financial Services</td>
<td>Scotland</td>
</tr>
</tbody>
</table>
but I am not sure if it is possible to add a hyperlink as an additional column to the table that links to a page using a hidden id.
So I would want something link this:
<table border="1">
<thead>
<tr>
<th>Job Title</th>
<th>Salary</th>
<th>Sector</th>
<th>Location</th>
<th>Apply</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dog walker</td>
<td>20000</td>
<td>None</td>
<td>London</td>
<td>Apply</td>
</tr>
<tr>
<td>F1 Driver</td>
<td>10000000</td>
<td>Financial Services</td>
<td>Scotland</td>
<td>Apply</td>
</tr>
</tbody>
</table>
Is that possible?
Yes, but you need to modify the $results array before you pass it to Smarty so that the 4th element of each row contains the link as a string. There's no way to have {html_table} generate the link for you.