how do i disable sorting when user clicks on Select object (when select object is in header)

how do i disable sorting when user clicks on Select object (when select object is in header)

edwinkohedwinkoh Posts: 7Questions: 2Answers: 0

Hi,
i added my filters below the header title usig
.appendTo( $(column.header()) )
the select does gets appended to the header. however, when i click on the select to filter the column, the SORT is triggered. even when i click on my selection, the SORT is activated a second time.

how do i separate the selection and sort functionality while keeping the select in the header cell.

Link to test case: https://jsfiddle.net/koh_edwin/m3510ybv/2/
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: clicking the select sorts the table

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Ideally you'd want to add a second header row - please see this example from this thread.

    If you want a single row, this example from this thread is demonstrating how to do that,

    Colin

  • edwinkohedwinkoh Posts: 7Questions: 2Answers: 0

    that was quick Colin, thanks for the swift response. let me try the 2nd sample. the first does not work for me as we didnt want the extra row.
    best,
    edwin

  • edwinkohedwinkoh Posts: 7Questions: 2Answers: 0

    Hi Colin,
    thanks for the code, its different than what i normally see in the samples and gives me a lot to explore.
    the requirements i have includes the use of a select box beneath the header. i modified your code to add SELECTs instead of inputs and right away i noticed that yor original INPUT element does not trigger a sort. however, when i replaced it with a select - sorting is still triggered - im back to where i started.
    i thought that the stop propagation would help but i added that into my select trigger but it didnt help.
    is there some limitation im hitting? or a setting im missing?

    thanks,
    edwin

    heres the new version where i just started building the select (havent gotten to populating the contents of the select but my issue persists - unwanted sorting). sorting is triggered when i click one of the SELECT options.

    https://jsfiddle.net/koh_edwin/5cs1oku0/3/

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    You can do something like this - it's mixing my previous example with this one.

    Hope that does the trick,

    Colin

Sign In or Register to comment.