Dynamically show or hide child row buttons

Dynamically show or hide child row buttons

pmconsultingpmconsulting Posts: 36Questions: 11Answers: 0

I have an array of additional records which is related to primary records already displaying in a DataTable at https://cellulardynamics.com/dev/samples.

Only some of the records have child data. How do I configure it so that the .details-control class only exists for rows that have child data?

Prior to initializing the table, I run an AJAX function to get the child row information and store this as JSON objects where each member lists the Catalog ID (same as column 2 of DataTable) and the HTML for that particular child row.

Then, in the DataTables function, I have tried 2 ways of removing this control:

        "initComplete": function(settings, json) {
            cirm_table.rows().every(function(rowIdx, tableLoop, rowLoop) {
                var data = this.data();
                var catalog_ID = data.CatalogID;
              console.log('catalog_ID = ' + catalog_ID + '     |     rowIdx = ' + rowIdx + '     |     tableLoop = ' + tableLoop + '     |     rowLoop = ' + rowLoop);
                if (ext_data[catalog_ID] == 'undefined'){
                    jQuery(row).removeClass("details-control");
                    // jQuery(node).find('.details-control').removeClass('.details-control');
                }
            });
        }

Neither ...removeClass statement removes the buttons from rows that do not have child data. How can I fix that?

This discussion has been closed.