+ Start a Discussion
LBSLBS 

Issue with DataTables in VF page : Uncaught TypeError: table.rows is not a function

I'm using DataTables in a VF page together with LDS. I basically loads some data to the table and there are check boxes for each and every row of data. So based on the user selection they should be able to delete selected rows(recods). Here is my JS code to get the selected records.
function getSelectedDataRowValues(tableId){

                var compTable = this[tableId.replace(/\-/g, '_')];
                alert(compTable);

                var dataRowNodes = compTable.rows().nodes();
                var dataRowValues = compTable.rows().data();

                var selectedDataRowValues = new Array();

                for(var i=0; i<dataRowNodes.length; i++){
                    var checkbox = j$(dataRowNodes[i].children[0].children[0]).find('input');
                    if (checkbox.prop('checked')){
                        selectedDataRowValues.push(dataRowValues[i]);
                    }
                }

                return selectedDataRowValues;
            }

But every time I run the code I keep getting following error.
Uncaught TypeError: compTable.rows is not a function
But when I used compTable.rows there were no issues. I'm using the latest DataTable version though. Here is my header though:
 
<apex:stylesheet value="{!URLFOR($Resource.DataTables, 'DataTables-1.10.13/media/css/jquery.dataTables.min.css')}"/>
<script src="{!URLFOR($Resource.DataTables, 'DataTables-1.10.13/media/js/jquery.dataTables.min.js')}"/>

What could go wrong here? Any suggestions? Or else is there any way to capture selected rows and process with them?

Thanks
Best Answer chosen by LBS
LBSLBS
Well infact i was able to figure out the issue. Had to use
var dtAPI = $('[id$=products-table]').DataTable();

format to call rows() and further