Re Filtering in datatables 1.10

Re Filtering in datatables 1.10

ChrisAChrisA Posts: 7Questions: 2Answers: 0

Hi,

I'm struggling with filtering using Datatables 1.10.

Before moving to 1.10, I had a web page that contained two datatables. Firstly, a groupedResultsTable. Secondly, a detailedResultsTable.

When I clicked on a row in the grouped results table, this filtered the detailed results table. I achieved this by adding a column in each table, which was then hidden. This column is a 'key' column. So, when clicking on on the groupedResultsTable, I teased the key out of that row, and passed it in to the detailedResultsTable filter.

E.g.....

        $('#groupedResultsTable tbody ').on('click','tr', function () {             


            var rowId = groupedTable.row(this).index();
            var key= groupedTable.cell(rowId, 14);

            detailedTable.fnFilter(key.data(),9);

            } );

This worked perfectly well, but with the new filter function, I'm struggling to see how I can pass the key from the grouped table into by detailed table.

Thanks in advance for any suggestions.....

Chris

This question has an accepted answers - jump to answer

Answers

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    Not sure on how you "pass it" from table to table, but you can take a look at the yadcf showcase and read the docs to see if it fits you

  • allanallan Posts: 63,771Questions: 1Answers: 10,510 Site admin
    Answer ✓

    It looks like you are already part using the 1.10 API. I've made two changed:

    1. Just use cell() directly rather than needing to get the row index
    2. Use column().search() rather than fnFilter.
    $('#groupedResultsTable tbody ').on('click','tr', function () {
        var key= groupedTable.cell(this, 14);
     
        detailedTable.column( 9 ).search(key.data()).draw();
    } );
    

    Allan

  • ChrisAChrisA Posts: 7Questions: 2Answers: 0

    Hi,

    Big help, worked a treat, thank you.

    Chris

This discussion has been closed.