Строка заголовка Datatable не перемещается при горизонтальной прокрутке строки таблицы - PullRequest
0 голосов
/ 10 апреля 2020

У меня есть данные на стороне сервера. здесь вертикальная прокрутка это рабочий файл. Но так как количество столбцов велико, когда я активировал scrollH как true, заголовок таблицы не перемещается / прокручивается. но строка таблицы прокручивается. Я прочитал много потоков в stackoverflow, например, scrollH: 100 et c. Но никто не работал для меня. Если кто-то может дать немного света, пожалуйста,

HTML Page

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css">
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" src="js/dataTables.scroller.js"></script>

<script type="text/javascript" language="javascript" >
        $(document).ready(function() {
           var dataTable =  $('#employee-grid').DataTable( {
            serverSide: true,
            ajax:{
                    url :"jobshistory.php", // json datasource
                    type: "post",  // method  , by default get
                    error: function(){  // error handling
                        $(".employee-grid-error").html("");
                        $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="11">No data found in the server</th></tr></tbody>');
                        $("#employee-grid_processing").css("display","none");
                    }
                },
            dom: "frtiS",
            scrollY: 120,
            scrollH: true,
            deferRender: true,
            scrollCollapse: true,
            scroller: {
                loadingIndicator: true
            },
            aaSorting: [[11, 'desc']]
            } );
            $("#employee-grid_filter").css("display","none");  // hiding global search box
        } );
    </script>


<div class="">
  <div class='scroll'>
        <table id="employee-grid"  cellpadding="0" cellspacing="0" border="0" class="display nowrap" width="100%">
            <thead>
                <tr>
                    <th>Well</th>
                    <th>Job</th>
                    <th>Act Date</th>
                    <th>Rush</th>
                    <th>LQC</th>
                    <th>F Pr</th>
                    <th>Prnt</th>
                    <th>Sign</th>
                    <th>Dispat</th>
                    <th>Epinet</th>
                    <th>Date of loading</th>
                    <th>User</th>
                    <th>Time of Edit</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

This way screen loads

This is the view after horizontally scrolled

1 Ответ

0 голосов
/ 10 апреля 2020

Я изменил код таким образом

sScrollX: true, 
scrollY: 120, 
scrollH: true, 

Теперь он работает

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...