Ellipsis renderer not working with mjoin?
Ellipsis renderer not working with mjoin?
peterbrowne
Posts: 314Questions: 54Answers: 0
in Editor
The following is not working for Ellipisis renderer on column 4 'unit outcome' which is using mjoin data. Not sure where the problem is though. The data from mjoin is wrapped in para tags. I can get ellipsis applied to other columns in this table no problem.
var table = $( '#unit_table' ).DataTable( {
responsive: true,
columnDefs: [ {
targets: 4,
render: $.fn.dataTable.render.ellipsis( 10, true )
} ],
ajax: "program_data/unit_data.php",
dom: "Blfrtip",
columns: [ {
data: "unit.unit_code"
}, {
data: "unit.unit_name"
}, {
data: "unit.points"
}, {
data: "year.year_name"
},{
data: "unit_outcome",
render: "[; ].unit_outcome"
}, {
data: "unit.modified"
}, {
data: "unit.modified_by"
} ],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [ ]
} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You have
And this in
columns
defined for column 4. I believe the
columns
definition has priority over thecolumnDefs
when there are conflicts. Try moving the ellipsis renderer to thecolumns
option.Kevin
Changing from columnDefs to columns makes no difference. In fact if I use columns and change the target to another column, no truncating occurs. So I don't think that Ellipsis works with columns.
Are you using the ellipsis renderer as described here?
https://datatables.net/manual/data/renderers#Custom-helpers
It works here defined in
columns
:http://live.datatables.net/divimoqi/1/edit
Doesn't look like there the function uses a second parameter,
ellipsis( 10, true )
.Kevin
Thanks, but my column already has a render for mjoin. Can I use both render for mjoin and ellipsis for the one column?
As Kevin said, they're clashing in the
columns
andcolumnDefs
, so you need to put the logic into a single place.Colin
Can you provide an example using what I have provided?
Since you can't combine render functions in
columns
then I would updated the ellipsis renderer to do what I want. In the function usejoin(';')
to join the array then return the string with ellipsis as needed. For example:http://live.datatables.net/pajobipe/1/edit
Kevin
Thanks.