Select value updating datatable but not dropdown, cannot select "All"

Select value updating datatable but not dropdown, cannot select "All"

oliverateroliverater Posts: 9Questions: 4Answers: 0

Hi there,

I am trying to add multiple dropdown searches to my datatables, which pull in data from Google Sheets. The dropdowns work, in that they update the table, however the option value in the select button does not update, and only displays the default "All" category. Selecting "All" also does not remove the filter, so I cannot retrieve the original datatable view.

If I remove the "escapeRegex" option, the values do update when a new selection is made, but then the datatable itself does not update. Any way of working out what is the problem? Haven't found anything about this in the forum.

Link to test case: http://live.datatables.net/zonacaku/1/edit?html,js,output

Thanks

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,125Questions: 26Answers: 4,916
    Answer ✓

    Allan posted an example in this thread of creating a cascading option filter. I think its what you are looking for.

    Kevin

  • oliverateroliverater Posts: 9Questions: 4Answers: 0

    Thank you, Kevin

    This resolves the issue. I am trying to stick the option filters for the first two columns in a separate container outside the table, however I can only return 1 of the columns.
    I have tried writing an array and selecting the indexes ie:

    this.api().columns([0, 1]).every( function () { ...
    

    But this only returns the 2nd column

  • kthorngrenkthorngren Posts: 21,125Questions: 26Answers: 4,916

    My guess is your selector is not changing fo each column so the first overwrites the second. Please update your test case to show what you are doing if you need further help.

    Kevin

  • oliverateroliverater Posts: 9Questions: 4Answers: 0

    Thanks for the prompt response.

    I have updated the test case: http://live.datatables.net/zonacaku/2/edit?html,js,output

    It looks like you're right, in that the first is overwritten by the second, but not sure why...

  • kthorngrenkthorngren Posts: 21,125Questions: 26Answers: 4,916
    Answer ✓

    .appendTo( $('.test').empty() )

    This is likely the problem. You will want to create an individual element for each select input and use the id instead of the class. You could use the column index as part of the id by using column().index().

    Kevin

  • oliverateroliverater Posts: 9Questions: 4Answers: 0

    Thanks Kevin, that fixed the problem!

This discussion has been closed.