Issue in footerCallback

Issue in footerCallback

zgoforthzgoforth Posts: 493Questions: 98Answers: 2

Link to test case: https://jsfiddle.net/BeerusDev/gbyks9r1/8/
I am trying to find an easier way to loop through all the days to get a count of all status so I can then create a simple switch statement to apply the count below my table instead of taking up like 160 lines in my other example. I call var data = this.data(), but it tells me in the next line data.flatMap is not a function? I am confused

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    You have this:

                      api.rows({search: 'applied'}).every(function (rowIdx, tableLoop, rowLoop, searchData){
                      var data = this.data();
    

    Inside the loop each this is one row meaning this.data(); is the same as row().data(). Debugging your code the row().data() is returning an object with that row's data.

    The flatMap() method is expecting an array of data not an object.

    If you want an array of all the rows try replacing the loop with this:

    var rowData = api.rows().data().toArray();
    rowData.flatMap( ... );
    

    The toArray() will return a standard Javascript array.

    Kevin

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    @kthorngren Thank you Kevin!

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    @kthorngren I am super stressed right now.. I cannot get it working. I accidentally deleted the fiddle in the OP and now I can't recreate what I had working, it tells me that rows() is not defined? https://jsfiddle.net/BeerusDev/gm10rqp7/355/

Sign In or Register to comment.