Sorting Taking Place automatically When Input Drop-down Filters moved to header

Sorting Taking Place automatically When Input Drop-down Filters moved to header

beginner_2018beginner_2018 Posts: 46Questions: 19Answers: 0
edited April 2018 in Free community support

Dear All,

I moved the input drop down from footer to header .Due to which sorting place for the column when ever I try to filter the column

fiddle

Can anyone please do let me know what is the issue at below line ,Are is it possible to give sort based on column text.

column.data().unique().sort().each(function (d, j) {
select.append('<option value="' + d + '">' + d + '</option>')
});

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @beginner_2018 ,

    Good to see it's all taking shape. It's not easy to have the ordering not affected by the sorting if they're on a single line. The best solution, as in this modification of your fiddle, is to have two header lines, one for the filter, and one for the sort.

    Hope that works for you,

    Cheers,

    Colin

  • beginner_2018beginner_2018 Posts: 46Questions: 19Answers: 0

    Tanks for your response Sir,

    I had added data-orderable="false" for one of the THEAD, And filters are working fine ,But could you please help me how can I point the sort to another header or THEAD

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I'm sorry, I don't understand that. You want the dropdown to contain values for another column?

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    Answer ✓

    This example uses search inputs but you should be able to do the same with a drop down search. It uses orderCellsTop to move the sorting event handlers to the top row.

    http://live.datatables.net/giharaka/1/edit

    Kevin

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Ah, I see, thanks Kevin, having a senior moment there. Yep, what he said.

This discussion has been closed.