Ellipsis renderer not working with mjoin?

Ellipsis renderer not working with mjoin?

peterbrownepeterbrowne Posts: 103Questions: 23Answers: 0

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

Answers

  • kthorngrenkthorngren Posts: 8,089Questions: 25Answers: 1,816

    You have

                    columnDefs: [ {
                        targets: 4,
                        render: $.fn.dataTable.render.ellipsis( 10, true )
                    } ],
    

    And this in columns

                    },{
                        data: "unit_outcome",
                        render: "[; ].unit_outcome"
                    }, 
    

    defined for column 4. I believe the columns definition has priority over the columnDefs when there are conflicts. Try moving the ellipsis renderer to the columns option.

    Kevin

  • peterbrownepeterbrowne Posts: 103Questions: 23Answers: 0

    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.

  • kthorngrenkthorngren Posts: 8,089Questions: 25Answers: 1,816

    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

  • peterbrownepeterbrowne Posts: 103Questions: 23Answers: 0

    Thanks, but my column already has a render for mjoin. Can I use both render for mjoin and ellipsis for the one column?

  • colincolin Posts: 8,013Questions: 0Answers: 1,348

    As Kevin said, they're clashing in the columns and columnDefs, so you need to put the logic into a single place.

    Colin

  • peterbrownepeterbrowne Posts: 103Questions: 23Answers: 0

    Can you provide an example using what I have provided?

  • kthorngrenkthorngren Posts: 8,089Questions: 25Answers: 1,816
    Answer ✓

    Since you can't combine render functions in columns then I would updated the ellipsis renderer to do what I want. In the function use join(';') to join the array then return the string with ellipsis as needed. For example:
    http://live.datatables.net/pajobipe/1/edit

    Kevin

  • peterbrownepeterbrowne Posts: 103Questions: 23Answers: 0

    Thanks.

Sign In or Register to comment.