Hello, I try to use the column.render to create an ellipsis for long content, but nothing happen
Hello, I try to use the column.render to create an ellipsis for long content, but nothing happen
Here is my link case : http://live.datatables.net/pupowexa/5/edit?html,js,output
in column 11 IssueText should be truncated after 10 characters with my render function:
ColumnDefs: [
{
"render": function (data, type, row, meta) {
return type === 'display' && data.length > 10 ?
'<span title="' + data + '">' + data.substr(0, 10) + '...</span>' :
data;
},
"targets": 7
},
I haven't any error shown.
(don't know if it's important, but { orderable: false, targets: [2, 3] } doen't seems to work )
thank you very much for your help !
This question has an accepted answers - jump to answer
Answers
Hi,
ColumnDefs
should becolumnDefs
- Javascript is case sensitive.Note also that you have HTML tags inside your column used to make the text red. You'll either need to account for that as part of the ellipsis calculation or, I would suggest, you use a class on the cells to assign a CSS style.
Allan
Thank you Very much. I will pay more attention to case now.
But I ended up in another issue.
If I use columnDefs.render AND I add html5 attibute data-search in a <td>,
Only my Select list is updated by my render, and not the column list (Current Step)
see http://live.datatables.net/pupowexa/17/edit?html,js,output
The same without data-search, and Current Step is well updated
http://live.datatables.net/beqequdo/1/edit
Any hint is welcome !
I'm not following the problem, as both look OK to me. But if you have a select that you're building yourself, then your code will need to consider the HTML5 attributes when you build it. If I'm not understanding the issue, please can you elaborate some more,
Colin
Thanks for your answer.
I've simplified a lot the code here in
http://live.datatables.net/qoviziju/1/edit
(some explanation in the code/html)
2 tables, the only difference is data-search attribute added in the 2nd table.
I loose the RED render you can see in table 1
You are right - when using a DOM sourced table with orthogonal data, it looks like the display renderer isn't running for some reason.
Are you going to be applying some logic to the colouring for those cells? If not, then using
columns.className
to assign a class would be the easiest option.Allan
Yep, I need to apply some logic.
As in http://live.datatables.net/qoviziju/5/edit?html,js,output
I've got a third column for issue. If the column is not empty (row[x].lenth > 1) then I need to render in red (and with a glyphicon ).
(I keep in mind the columns.className for other styling I've got in mind !)