How to read through all cells in a column with a paging datatable?

How to read through all cells in a column with a paging datatable?

Keith_HKeith_H Posts: 54Questions: 19Answers: 1
edited November 2018 in Free community support

This is with datatables 1.10.15.

I create a table:

    '#tblOpsMassRepl').DataTable({
      "autoWidth":false
    , "info":true
    , "JQueryUI":true
    , "Order":[0,'asc']
    , "ordering":true
    , "paging":true
    , "pageLength": 27
    , "lengthChange": false
    , "scroller":true
    , "scrollCollapse":true
    ,"drawCallback": function( settings ) {fncAddEventsAndStripes($(this).attr('id'));}
    })

I fill it:

    var locTable        = $('#tblOpsMassRepl).DataTable();
    var locIconChk  = '';
    var locHidId        = '';

    locTable.clear();

    for (var i = 0; i < pData.length; i++) {
        locIconChk  = '<input type="checkbox" name="chkOpsMassRepl" id="chkOpsMassRepl'+i+'" class="JqUiCheckBox" />';
        locHidId        = '<input type="hidden" name="hidOpsMassRepl" id="hidOpsMassRepl'+i+'" value="'+trim(pData[i].PART) + '_' + fncFormatNumber(pData[i].PATH,0,"Y") + '_' + fncFormatNumber(pData[i].OP,0,"Y") +'" />';

        locTable.row.add([
             pData[i].PART
            ,pData[i].DESC
            ,pData[i].COMMODITY
            ,fncFormatNumber(pData[i].PATH,0,"Y")
            ,fncFormatNumber(pData[i].OP,0,"Y")
            ,locIconChk + locHidId
        ]);
    }
    locTable.draw().columns.adjust();

I want to be able to read all checked checkboxes from all pages and then use this to pass an array to an update program (I know how to build the array, the problem is understanding how to loop through the datatable data.

I've started with something like

    locTable.columns(5)....
or
    locTable.columns(5).every(function() {});

But I don't know how to get the data (which will be both the checkbox and hidden field) so I can check/manipulate these to build my parameters for the update.

Any help appreciated.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @Keith_H ,

    The data for that column could be read with column().data(), which you can then parse. The last example on filter()sounds like it may also do the trick for you.

    Cheers,

    Colin

This discussion has been closed.