tag in HTML title breaks pdfmake export in jQuery DataTables
I am trying to format how the data is displayed in a jquery DataTable.
If the text is long, I truncate it like below:
{
"data": "col1", "render": function (data, type, row) {
if (type === 'display' && data != null) {
data = data.replace(/<(?:.|\n)*?>/gm, '');
data = data.split("; ").join("<br/>");
if (data.length > 85) {
return '<span class="show-ellipsis" title="'+data+'">' + data.substr(0, 85) + '</span><span class="no-show">' + data.substr(85) + '</span>';
} else {
return data;
}
} else {
return data;
}
}
},
and use the following CSS alongside jquery UI tooltip.
CSS
span.no-show {
display: none;
}
span.show-ellipsis:after {
content: "...";
}
jQuery UI tooltip
<script>
$(function () {
$(document).tooltip({
items: 'span.show-ellipsis',
content: function () {
return $(this).attr('title');
},
position: {
my: "center bottom",
at: "center top-10",
collision: "flip",
using: function (position, feedback) {
$(this).addClass(feedback.vertical)
.css(position);
}
}
});
});
This way it appears nicely in the DataTable,
The screenshot above had <hr>
instead of <br/>
tag in replace method, but the behavior remains the same. It works fine if I replace with n
. When I try to export the pdf, data gets repeated. In particular the data.substr(85) part.
What am I doing wrong?
Thank you
javascript jquery html datatables pdfmake
add a comment |
I am trying to format how the data is displayed in a jquery DataTable.
If the text is long, I truncate it like below:
{
"data": "col1", "render": function (data, type, row) {
if (type === 'display' && data != null) {
data = data.replace(/<(?:.|\n)*?>/gm, '');
data = data.split("; ").join("<br/>");
if (data.length > 85) {
return '<span class="show-ellipsis" title="'+data+'">' + data.substr(0, 85) + '</span><span class="no-show">' + data.substr(85) + '</span>';
} else {
return data;
}
} else {
return data;
}
}
},
and use the following CSS alongside jquery UI tooltip.
CSS
span.no-show {
display: none;
}
span.show-ellipsis:after {
content: "...";
}
jQuery UI tooltip
<script>
$(function () {
$(document).tooltip({
items: 'span.show-ellipsis',
content: function () {
return $(this).attr('title');
},
position: {
my: "center bottom",
at: "center top-10",
collision: "flip",
using: function (position, feedback) {
$(this).addClass(feedback.vertical)
.css(position);
}
}
});
});
This way it appears nicely in the DataTable,
The screenshot above had <hr>
instead of <br/>
tag in replace method, but the behavior remains the same. It works fine if I replace with n
. When I try to export the pdf, data gets repeated. In particular the data.substr(85) part.
What am I doing wrong?
Thank you
javascript jquery html datatables pdfmake
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
Yes thedisplay: none
part. But why does it take it into consideration when the method is called like thisdata = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28
add a comment |
I am trying to format how the data is displayed in a jquery DataTable.
If the text is long, I truncate it like below:
{
"data": "col1", "render": function (data, type, row) {
if (type === 'display' && data != null) {
data = data.replace(/<(?:.|\n)*?>/gm, '');
data = data.split("; ").join("<br/>");
if (data.length > 85) {
return '<span class="show-ellipsis" title="'+data+'">' + data.substr(0, 85) + '</span><span class="no-show">' + data.substr(85) + '</span>';
} else {
return data;
}
} else {
return data;
}
}
},
and use the following CSS alongside jquery UI tooltip.
CSS
span.no-show {
display: none;
}
span.show-ellipsis:after {
content: "...";
}
jQuery UI tooltip
<script>
$(function () {
$(document).tooltip({
items: 'span.show-ellipsis',
content: function () {
return $(this).attr('title');
},
position: {
my: "center bottom",
at: "center top-10",
collision: "flip",
using: function (position, feedback) {
$(this).addClass(feedback.vertical)
.css(position);
}
}
});
});
This way it appears nicely in the DataTable,
The screenshot above had <hr>
instead of <br/>
tag in replace method, but the behavior remains the same. It works fine if I replace with n
. When I try to export the pdf, data gets repeated. In particular the data.substr(85) part.
What am I doing wrong?
Thank you
javascript jquery html datatables pdfmake
I am trying to format how the data is displayed in a jquery DataTable.
If the text is long, I truncate it like below:
{
"data": "col1", "render": function (data, type, row) {
if (type === 'display' && data != null) {
data = data.replace(/<(?:.|\n)*?>/gm, '');
data = data.split("; ").join("<br/>");
if (data.length > 85) {
return '<span class="show-ellipsis" title="'+data+'">' + data.substr(0, 85) + '</span><span class="no-show">' + data.substr(85) + '</span>';
} else {
return data;
}
} else {
return data;
}
}
},
and use the following CSS alongside jquery UI tooltip.
CSS
span.no-show {
display: none;
}
span.show-ellipsis:after {
content: "...";
}
jQuery UI tooltip
<script>
$(function () {
$(document).tooltip({
items: 'span.show-ellipsis',
content: function () {
return $(this).attr('title');
},
position: {
my: "center bottom",
at: "center top-10",
collision: "flip",
using: function (position, feedback) {
$(this).addClass(feedback.vertical)
.css(position);
}
}
});
});
This way it appears nicely in the DataTable,
The screenshot above had <hr>
instead of <br/>
tag in replace method, but the behavior remains the same. It works fine if I replace with n
. When I try to export the pdf, data gets repeated. In particular the data.substr(85) part.
What am I doing wrong?
Thank you
javascript jquery html datatables pdfmake
javascript jquery html datatables pdfmake
asked Nov 14 '18 at 11:23
JasonAJasonA
285
285
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
Yes thedisplay: none
part. But why does it take it into consideration when the method is called like thisdata = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28
add a comment |
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
Yes thedisplay: none
part. But why does it take it into consideration when the method is called like thisdata = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
Yes the
display: none
part. But why does it take it into consideration when the method is called like this data = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28
Yes the
display: none
part. But why does it take it into consideration when the method is called like this data = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28
add a comment |
1 Answer
1
active
oldest
votes
ok, in your button
extend: 'pdfHtml5',
exportOptions: {
orthogonal: 'export',
}
in your columns :
render: function (data, type, row) {
return type === 'export' ? row.Descripcion: "";
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299077%2fbr-tag-in-html-title-breaks-pdfmake-export-in-jquery-datatables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ok, in your button
extend: 'pdfHtml5',
exportOptions: {
orthogonal: 'export',
}
in your columns :
render: function (data, type, row) {
return type === 'export' ? row.Descripcion: "";
}
add a comment |
ok, in your button
extend: 'pdfHtml5',
exportOptions: {
orthogonal: 'export',
}
in your columns :
render: function (data, type, row) {
return type === 'export' ? row.Descripcion: "";
}
add a comment |
ok, in your button
extend: 'pdfHtml5',
exportOptions: {
orthogonal: 'export',
}
in your columns :
render: function (data, type, row) {
return type === 'export' ? row.Descripcion: "";
}
ok, in your button
extend: 'pdfHtml5',
exportOptions: {
orthogonal: 'export',
}
in your columns :
render: function (data, type, row) {
return type === 'export' ? row.Descripcion: "";
}
answered Nov 14 '18 at 19:55
Wilmer Ofelio Alama SeminarioWilmer Ofelio Alama Seminario
6916
6916
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299077%2fbr-tag-in-html-title-breaks-pdfmake-export-in-jquery-datatables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's like your exported PDF does not take the CSS in consideration no?
– CrazyProg
Nov 14 '18 at 12:25
Yes the
display: none
part. But why does it take it into consideration when the method is called like thisdata = data.split("; ").join("n"); ?
– JasonA
Nov 14 '18 at 12:28