Script formatting question

Script formatting question

farawaypressfarawaypress Posts: 9Questions: 4Answers: 0

This should, I hope, be a very simple question, but it has eluded my meager understanding of Java.

I'm trying to toggle childRowImmediate in specific tables, but while I see the instruction is to write it as...

$('#myTable').DataTable( {
    responsive: {
        details: {
            display: $.fn.dataTable.Responsive.display.childRowImmediate
        }
    }
} );

...I need to incorporate it into my existing script which is atop my table:

$(document).ready( function () {
        $('#TopPostalComics').DataTable( {
    fixedHeader: true, responsive: true, "lengthMenu": [ [25, 50, 100, -1], [25, 50, 100, "All"] ]
        });
} );

Whenever I try to merge these, things go wrong. How should a block merging these commands look?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    Many times its because people forget to add a comma to separate the options. Try this:

    $('#myTable').DataTable( {
        responsive: {
            details: {
                display: $.fn.dataTable.Responsive.display.childRowImmediate
            }
        },  // make sure to add the comma
        fixedHeader: true,
         "lengthMenu": [ [25, 50, 100, -1], [25, 50, 100, "All"] ]
    } );
    

    Kevin

  • farawaypressfarawaypress Posts: 9Questions: 4Answers: 0

    Thanks! Sadly, it didn't appear to work. I now have...

    $(document).ready( function () {
            $('#TopPostalComics').DataTable( {
         responsive: {
            details: {
                display: $.fn.dataTable.Responsive.display.childRowImmediate
            }
        }, 
                fixedHeader: true, responsive: true, "lengthMenu": [ [25, 50, 100, -1], [25, 50, 100, "All"] ]
            });
    } );
    

    The responsive command is execited, but the child rows are still hidden on mobile. (and fixedHeader isn't working now either).

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    Answer ✓

    Remove the ‘responsive: true’. Its overwriting the previous responsive option. Thats why it wasn’t t in my example.

    Kevin

  • farawaypressfarawaypress Posts: 9Questions: 4Answers: 0

    Ah, that did it. Thank you very much!

This discussion has been closed.