can a line break be added to language shown in the info feature?

can a line break be added to language shown in the info feature?

tdemelletdemelle Posts: 2Questions: 1Answers: 0

I'd like to have '1 row selected' on a second line under 'showing...'

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 3,048Questions: 88Answers: 424
    edited February 3 Answer ✓

    Just add this to your datatable's event handlers:

    table
        .on ('init select deselect', function () {
            $('span.select-info > span.select-item').prepend("<br>");
        });
    
  • allanallan Posts: 63,966Questions: 1Answers: 10,547 Site admin

    Another option is via CSS:

    div.dt-container span.select-info {
      display: block;
      margin-left: 0;
    }
    

    Allan

  • rf1234rf1234 Posts: 3,048Questions: 88Answers: 424

    Hi Allan,

    your selector didn't work with my version of Data Tables (which is older).

    And I think you need to add the CSS dynamically after DT initialization. I added it on "init" but I also had to add it on "select" and "deselect". Otherwise it didn't work.

    This works:

    table
        .on ('init select deselect', function () {
            $('span.select-info > span.select-item').css({ 'display': 'block',
                                                           'margin-left': 0    });
        });
    

    Roland

  • allanallan Posts: 63,966Questions: 1Answers: 10,547 Site admin
    edited February 3

    If you are still using 1.x then the selector to use would be:

    div.dataTables_wrapper span.select-info {
      display: block;
      margin-left: 0;
    }
    

    https://live.datatables.net/qevakili/1/edit

    Allan

  • tdemelletdemelle Posts: 2Questions: 1Answers: 0
    edited February 3

    Thank you!
    This CSS keeps the 2nd line from jumping when rows are selected.

    .dt-info {
        position: relative;
        margin-bottom: 0.5em;
     }
     
     .select-info {
        position: absolute;
        top: 0.5em;
        left: 0;
     }
    
Sign In or Register to comment.