ordering buttons on first row (thead with 2rows)

ordering buttons on first row (thead with 2rows)

clintjie_loclintjie_lo Posts: 4Questions: 3Answers: 0

hi guys so i am following this bin to includescrollX with my datatable:
http://live.datatables.net/mivaresa/1/edit

now i've edited it to:
http://live.datatables.net/mivaresa/22/watch?html,js,output

my problem is the ordering and the <seclect> all apply to the very last <tr> i made for <thead>, is there a way for the ordering buttons to appear on the very first <tr>. I tried ordercellstop: true and the <select> just goes with it.

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43
    edited October 2015

    Your original question was about clicking on the select box and having that trigger the column sort. The issue is the the click that triggers the sort event is on the TD that holds both the icon and filter buttons.

    I think I played with two ways to get around this.

    1. Use jQuery to move the select boxes up one level. This worked a little, but I think it was hard to work with fixed headers
    2. Use the select2 ibrary (not the datatables plugin for it) to restyle the select boxes.

    I'm using option 2. It is easy to implement and I think it is how I solved the problem.

    Once you include the select2.js and css files, implementing it is easy. The two config lines are optional.

    I have a class added to columns where I want a select box.

    $('.ratingSelect select').select2({
            width: 'resolve",   //gives me an auto width
            placeholder: "Select a value"
    });
    
    
  • clintjie_loclintjie_lo Posts: 4Questions: 3Answers: 0
    edited October 2015

    wow ThomD thanks for your help, i will try to implement this in my project. This the first time i've heard of this library will update you guys how it's going. Thank you very much

    Edit: so i tried using the library you told me but can you give me a sample how to achieve what i need, i'm still studying how to reposition it and I'm still a bit confused

This discussion has been closed.