Losing jquery styling when specifiying dom options

Losing jquery styling when specifiying dom options

kvickerykvickery Posts: 2Questions: 1Answers: 1

I am adding Buttons to my DataTable as shown below. All is good, except as soon as I add the "dom" options (to get rid of the default page length changer) the jquery styling of the header is gone - so the header is just a white background. How can I retain the jquery styling when specifying "dom" options?

var transactions = $('#Transactions').DataTable({
    "dom": '<"toolbar">"frtip',
    "bJQueryUI": true,
        buttons: ['pageLength',
          { extend: 'colvis',
            columns: ':not(.noColvis)',
            postfixButtons: [{extend:'columnToggle',
                              text:'Toggle multiple',
                              columns:'.hideInitial'
                             }]
          }]
      });

transactions.buttons().container().prependTo( transactions.table().container() );

This question has an accepted answers - jump to answer

Answers

  • kvickerykvickery Posts: 2Questions: 1Answers: 1
    Answer ✓

    Solved my own problem. Just needed to add in the H and F options into the DOM so that the header and footer were included. Also added in the B option to position the buttons within the header - so no need for the container prepend after.

    var transactions = $('#Transactions').DataTable({
        "dom": '<"H"Bf>rt<"F"irp>',
        "bJQueryUI": true,
            buttons: ['pageLength',
              { extend: 'colvis',
                columns: ':not(.noColvis)',
                postfixButtons: [{extend:'columnToggle',
                                  text:'Toggle multiple',
                                  columns:'.hideInitial'
                                 }]
              }]
          });
    
  • allanallan Posts: 62,088Questions: 1Answers: 10,180 Site admin

    Thanks for posting back - good to hear you've got it working!

    The dom option is a pain for certain. I'm going to address that in the next major version.

    Allan

This discussion has been closed.