Iterating through columns with a check box with the box that is checked

Iterating through columns with a check box with the box that is checked

vsekvsek Posts: 30Questions: 17Answers: 0
edited April 2021 in Free community support

Hello, I have this rendering fine. I want to have the user click on the "add" button and do the back end save code with only the ones with the check box selected.
Since I use the "columnDefs" to generate the check box on column = 0. Is there a way to collect a list of these inside the datatable? I attempt it with my 'list' var but its always "undefined" so there must be a "slick' way of retrieving these?

$(document).ready(function() {
        var dataTableId = '#standard_datatable';            
        // Data Table
        var table = $(dataTableId).DataTable({
            ajaxSource : "/cma/contents/screening/restrictedEntityGroupDetails_data?groupName=<%= (String)request.getAttribute("groupName")%>", 
            dom: 'Bfrtip', 
            buttons: [ 
            {  text: 'Add',
                    action: function ( e, dt, node, config ) {  
            var list = table.row( $(this).parents('tr') ).data(); 
            var result = $.ajax({
             type: 'POST', 
             url:"/cma/contents/screening/restrictedEntityGroupDetails_data_edit" ,
             data: {'tableData' : list},
             context: this
         }); 

             }  
   },
                  'copy', 'excel', 'pdf', 'searchBuilder'
               ],
               'columnDefs': [
                    {
                     'targets': 0,  
                     'checkboxes': {
                     'selectRow': true
                                 },
                     'createdCell':  function (td, cellData, rowData, row, col){
                        if(rowData[0] === '1')
                            {
                            this.api().cell(td).checkboxes.select(); 
                            }
                        }
                    },    
                    
            ],
            'order': [ [ 2, 'asc' ], [ 3, 'asc' ]]
            
        }); 

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

This discussion has been closed.