api.column().data() don't work with serach pannes on drawCallback

api.column().data() don't work with serach pannes on drawCallback

acroposeacropose Posts: 11Questions: 3Answers: 0
edited April 2021 in SearchPanes

Hey,
I want to make the sum of every row of a column, to do this I have use column().data() with page: "current" in parametter in drawCallback.And It works as soon as I don't use search panes. When I use search panes column().data() send me data without filtre.

It appends every first time I click on a search pane without a filter before.

Here is my test case : https://jsfiddle.net/w17xceov/

Thanks you in advance ;)

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    You can use the selector-modifier of {search: 'applied}` to get only the data shown after the filter. You can combine both search and page in one object to apply both.

    Kevin

  • acroposeacropose Posts: 11Questions: 3Answers: 0

    Fantastic! That works fine, sometimes I'm just stupid x)

  • acroposeacropose Posts: 11Questions: 3Answers: 0
    edited April 2021

    I have a new issue with the same test case but with the search parametter in column.
    When my table footer is fixed the text don't be updated.
    Don't know where that could come from

  • acroposeacropose Posts: 11Questions: 3Answers: 0
    edited April 2021

    ok it's beacose datatable create another table when is fixed so I just have to do this :

                        const footTable = document.getElementsByTagName("TFOOT");
    
                        for(let i = 0; i < footTable.length; i++) {
                            footTable[i].rows[0].cells[1].innerText = Math.round(sum * 100) / 100 + "€"
                        }
    
This discussion has been closed.