The Print extension is not printing in a right structure, what is wrong with my code
The Print extension is not printing in a right structure, what is wrong with my code
Snehitha
Posts: 4Questions: 1Answers: 0
This is the html file
Name | Position | Office | Extn. | Start date | Salary |
---|
And this is my service.js where i am getting the values from
var dataSrc= [
{
"name": "Deepa",
"position":"Developer",
"office":"Edinburgh",
"extn":"5421",
"date":"2011/04/25",
"salary":"$320,800"
},
{
"name": "Atul",
"position":"Team Lead",
"office":"Edinburgh",
"extn":"5421",
"date":"2011/04/25",
"salary":"$320,800"
},
{
"name": "Ravi",
"position":"System Architect",
"office":"Edinburgh",
"extn":"5421",
"date":"2011/04/25",
"salary":"$320,800"
},
];
$(document).ready(function(){
if ($.fn.DataTable.isDataTable("#dtb_print_test")) {
$('#dtb_print_test').DataTable().clear().destroy();
}
let table=$('#dtb_print_test').DataTable({
"columnDefs": [
{
"targets": [ 2 ],
"visible": false,
"searchable": false
},
{
"targets": [ 3 ],
"visible": false
}
],
dom: 'Bfrtip',
buttons: [{extend: "print"},'excelHtml5','csvHtml5','pdfHtml5']
})
table.clear();
$.each(dataSrc,function(k,v){
var row=table.row.add([
v.name,
v.position,
v.office,
v.extn,
v.date,
v.salary,
])
row.draw();
});
})
The below is the pattern of how my datatable is getting printed
This discussion has been closed.
Answers
Hi @Snehitha ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hello @colin thanks, sure, but it seems to be working fine here, and not in my code at the template, would that be a template related issue?
https://jsfiddle.net/47shz81t/14/
Hope this is the test case you are talking about.
Hi @Snehitha ,
Yep, thanks for the test case. As it's working fine there, as you say, it must be something in your templates or something else external, I'm afraid. Unless we can see it behaving in that way, it's hard to make recommendations,
Cheers,
Colin
Thanks @colin, if i could share the template/code i am working with, how could i share that with you?
It would be easier if you could link to a page that demonstrates the issue, so we can look at that. Templates will be dependent upon environment and packages which would be too much for us to setup...
@colin, i am not sure i know a way to share the demonstration of the issue, all that i could for now say is the issue is the image(screen shot) attached with this post, could that be of any help in you being able to guide me on the possible issue at my side to get the print in a right structure, Thanks.