Filter column with selectlist cells

Filter column with selectlist cells

CezarrCezarr Posts: 8Questions: 3Answers: 1

I'd like to filter column using select list in footer. Column's cells datas are select lists. How can I filter that data? I assume I have to search somewhere by 'selected' option, but have no idea where exactly.

Here is example

This question has an accepted answers - jump to answer

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi Cezarr,

    I'm afraid that at the moment DataTables does not support this using the API or otherwise. It is however possible to accomplish this by writing your own function.

    You can find some details on writing a custom filtering function here.

    Thanks,

    Sandy

  • CezarrCezarr Posts: 8Questions: 3Answers: 1
    Answer ✓

    For anybody with same problem I wrote something like this:

    $.fn.dataTable.ext.search.push(
            function (settings, data, dataIndex) {
                if (settings.nTable.id !== 'activeItemsTable') {
                    return true;
                }
                var selectedValue = $('#CategoryFilter').val();
                var cellSelectedValue = $(activeTable.row(dataIndex).data()[1]).val();
    
                if (selectedValue == cellSelectedValue || selectedValue == -1) {
                    return true;
                }
                return false;
            }
        );
    
This discussion has been closed.