我该如何解决这个Jquery DataTable问题?

时间:2017-08-01 05:35:58

标签: jquery jquery-plugins datatables

数据表中的数据已填充

1.issue 1:显示" 显示1到1的100 "是错的。

2.issue 2:当我在数据表中滚动时,它无法正常显示。

1.注1:当我按下" f12 "键盘键问题1将自动修复

2.注2:当我点击可排序列时,问题2将自动修复

问题1的图片 image

问题2的图像"当滚动表时,它将像下面的图像" Image

我已使用此代码 javascript代码

function createCompanyDataTable(colsArray, recordPerPage, dataTableDiv) {
    // fetch columnDefs for hide columns based on user preference while initializing datatable
    var columnDefs = fetchColumnDefs(colsArray);
    // fetch column indexes not excluded from the process of hide/show column
    var columnIndexesNotExcludedForColumnVisibility = fetchColumnsNotExcludedForColumnVisibility(colsArray);
    var table = $(dataTableDiv).DataTable({
        /*ajax : dataAjaxUrl,*/
        columns : colsArray,
        scrollX: true,
        scrollY: 350,
        displayLength: -1,
        scrollX: true,
        deferRender: true,
        scrollCollapse: true,
        order: [],
        scroller: true,
        dom: 'R<"columns-button"B>ft<"span12"<"span4"><"span4"i><"span4">>',
        // set column default preferences
        columnDefs: columnDefs,
        lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
        buttons: [
          {
            extend:'colvis',
            className : 'btn btn-primary',
            text: '<i class="fa fa-columns"></i>&nbsp;Columns',
            columns: columnIndexesNotExcludedForColumnVisibility
          },
          {
                 extend: 'collection',
                 text: 'Export',
                 className : 'btn btn-primary export-btn',
                 buttons: [
                           {
                               extend: 'excelHtml5',
                               filename: function(){
                                   var fileName = "Company List By Query" + (companyQueryText==""?"":" - "+companyQueryText); 
                                   return fileName.substring(0,250);
                               },
                               exportOptions: {
                                   columns: [0, 1, 2, 3, 4, 5, 6]
                               }
                           },
                       ],
          }
        ]
    });
    datatableScrollConfig(table);
    table.on( 'column-visibility.dt', function ( e, settings, column, state ) {
        saveDatatablePreferenceForColumnVisibility($(datatableId).DataTable());
    });
    return table;
}   

0 个答案:

没有答案