Error making column visible when using scrollY

Error making column visible when using scrollY

AndrewWilcoxAndrewWilcox Posts: 3Questions: 1Answers: 0
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Test</title>
    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css">
    <script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.js"></script>
    <script>
        $(function () {
            var dataSet = [
                    ["1", "2", "3", "4"],
                    ["1", "2", "3", "4"],
                    ["1", "2", "3", "4"]
            ];
            example = $('#example').DataTable({
                data: dataSet,
                scrollY: 600,
                columns: [
                    { title: "One", visible: false },
                    { title: "Two" },
                    { title: "Three" },
                    { title: "Four" }
                ]
            });

            example.column(0).visible(true);
        });
    </script>
</head>
<body>
    <table id="example" class="display" cellspacing="0" width="100%">
    </table>
</body>
</html>

Results in

Uncaught TypeError: Cannot read property 'style' of undefined
_fnCalculateColumnWidths @ jquery.dataTables.js:4165
_fnAdjustColumnSizing @ jquery.dataTables.js:764
__setColumnVis @ jquery.dataTables.js:8292
(anonymous function) @ jquery.dataTables.js:8370
_Api.iterator @ jquery.dataTables.js:6905
(anonymous function) @ jquery.dataTables.js:8366
(anonymous function) @ jquery.dataTables.js:7154
_Api.extend.methodScoping @ jquery.dataTables.js:7038
(anonymous function) @ test.html:28
x.Callbacks.c @ jquery-1.10.2.min.js:4
x.Callbacks.p.fireWith @ jquery-1.10.2.min.js:4
x.extend.ready @ jquery-1.10.2.min.js:4
q @ jquery-1.10.2.min.js:4

If I remove the scrollY option, the error doesn't occur.

Answers

  • seenimuruganseenimurugan Posts: 1Questions: 0Answers: 0

    My workaround for this issue is

    example.column(0).visible(true, false);

    Just disabled the redrawCalculations.

This discussion has been closed.