Iterating through current visible (filtered) rows only, column by column

Iterating through current visible (filtered) rows only, column by column

jLinuxjLinux Posts: 981Questions: 73Answers: 75
edited April 2016 in Free community support

First off.. HI @allan! Long time no talk.

Ok.. I'm working on one of my DT plugins, which I just found a bug in, and its been a while since I went on my DataTables coding binge, so I need a little help.

Basically, I need to iterate through the current visible rows on the table, column by column. I know I can use the columns().every() to iterate over the columns, then use this.data() to get the data (rows) in that column, but I just realized that if theres a search that filtered the rows on the table, then I need to do something different.

// Iterate through table, column by column..
api.columns().every( function() {
    var data = this.data().toArray()
    
    // Now loop through the rows in each column...
    // How can I ONLY loop through the visible rows here?
    for( var i = info.start; i < info.end; i ++ ) {
        // Do something..
    }
} )

I know that I could use the rows().data() with a row-selector or selector-modifier, but that would throw off the column by column iteration, which is something I really need, so id like to go column by column if possible

Thanks!

Update: Heres a snippet with some code that can be used to test this out. you can see on the 15th line (with var data = this.data().toArray()), I'm getting the entire columns data, but I want just the visible rows

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    I think I figured it out here If someone can take a look and confirm it.. that would be great :)

This discussion has been closed.