No change on filter

No change on filter

scpfiscpfi Posts: 4Questions: 2Answers: 0

I am trying to filter the results shown in my datatable when choosing from a dropdown (on a certain value of the dropdown, eg. 'All' the whole table should be visible again - thus the'').draw();
I am using the code below and although the true and false values are returned correctly there is no change on the datatable.
Do you have any pieces of advice?

$("#timeframe_data_dropdown li a").click(function(){
        var table_data = $('#bot_table_data').DataTable();
        if ($(this).text() != 'All') {
            var date_ago = moment().format('DD.MM.YY, HH:mm');

            if ("Last 7 days" == $(this).text()) {
                date_ago = moment().subtract(7, 'days');
            else if ("Last 30 days" == $(this).text()) {
                date_ago = moment().subtract(30, 'days');
            else if ("Last 90 days" == $(this).text()) {
                date_ago = moment().subtract(90, 'days');
            else if ("Last 180 days" == $(this).text()) {
                date_ago = moment().subtract(180, 'days');
            else {
                date_ago = moment().subtract(365, 'days');
            var filteredData = table_data.column(11).data().filter(function ( value, index ) {
                var date_dataset = moment(value, 'DD.MM.YY, HH:mm');
                return date_ago.isBefore(date_dataset);
            } ).draw();
        else {

This question has an accepted answers - jump to answer


  • scpfiscpfi Posts: 4Questions: 2Answers: 0

    I have read online that it might be impossible to use search and filter functions (and $ when loading data using ajax calls.
    Is that true?

  • kthorngrenkthorngren Posts: 4,846Questions: 19Answers: 1,067
    Answer ✓

    Yes, if you are using server side processing. If you have server side processing enabled then the search functionality is the performed by your server script.

    However if you don't have SSP enabled you can use the above with ajax loading of the data. If this is the case then please post a link to your page or a test case so we can help debug.


Sign In or Register to comment.