0

To remove striping on Datatables you add:

stripeClasses:[]

But I have the following styling added to change background cell color depending on the value of the cell:

        var table = $('#driverTable').DataTable({
            paging: false,
            scrollX: true,
            order: [[2, 'desc']],
            drawCallback: function (settings) {
                applyConditionalFormatting(this.api());
            },
            stripeClasses: []
        });
        $('input.toggle-vis').on('change', function (e) {
            e.preventDefault();

            var column = table.column($(this).attr('data-column'));
            column.visible($(this).prop('checked'));
        });
        function applyConditionalFormatting(table) {
            var higherIsBetter = {
                1: true,  // Races Count
                2: true,  // Rating
                3: false, // Start Position
            };
            for (var colIndex = 1; colIndex <= 17; colIndex++) {

                // Get all data in this column
                var data = table.column(colIndex, { search: 'applied' }).data();

                if (values.length > 0) {
                    var min = Math.min.apply(null, values);
                    var max = Math.max.apply(null, values);

                    // For each cell in this column
                    table.column(colIndex, { search: 'applied' }).nodes().each(function (cell, i) {
                       
                            }
                            // Set background color
                            var color = 'hsl(' + hue + ', 100%, 75%)'; // Adjust lightness as needed


And it adds the striping overtop the custom styling I added.

How do I remove the striping?

1 Answer 1

1

I figured it out.

My table had a class="display" on it. This applies default styling no matter what even if I add stripeClasses:[]

After removing the class attribute it removed the stripes!

Sign up to request clarification or add additional context in comments.

1 Comment

See Default styling options. The DataTables documentation is helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.