jQuery Datatables Header Misaligned With Vertical Scrolling

前端 未结 20 2561
北海茫月
北海茫月 2020-12-15 05:05

I\'ve posted this in the datatables.net forums, but after a week, still no response. Hopefully I can find help here...

I\'m using datatables version 1.8.1 and am ha

20条回答
  •  遥遥无期
    2020-12-15 05:10

    This is how I have got rid of this problem:

    I use this generally to execute functions after a Ajax call has been completed

        WaAjaxHelper = {
        arr_execute_after_ajax: null,
        add_function_to_execute_after_ajax: function (fun) {
    
            if (typeof fun == 'function') {
                if (!this.arr_execute_after_ajax) {
                    this.arr_execute_after_ajax = [];
                }
                this.arr_execute_after_ajax.push(fun)
                return true;
            } else {
                alert('ERROR: WaAjaxHelper.add_function_to_execute_after_ajax only functions possible');
                return false;
            }
        },
        execute_after_ajax: function () {
            if (this.arr_execute_after_ajax) {
                $.each(this.arr_execute_after_ajax, function (index, value) {
                    try {
                        value();
    
                    } catch (e) {
                        console.log(e);
                    }
                })
            }
            this.arr_execute_after_ajax = null;
        }
    }
    
    
    $(document).ready(function () {
        $.ajaxSetup({
            async: true,
            beforeSend: function (xhr) {
                xhr.setRequestHeader("Accept", "text/javascript");
                $('.blockUI').css('cursor', 'progress');
            },
            complete: function (jqXHR, textStatus) {
                $('body').removeClass('waiting');
            },
            error: function (jqXHR, textStatus, errThrown) {
                alert("Ajax request failed with error: " + errThrown);
                ajax_stop();
            }
        });
        $(document).ajaxStart(ajax_start).ajaxStop(ajax_stop);
    });
    
    
    ajax_start = function () {
        // do something here
    }
    ajax_stop = function () {
       WaAjaxHelper.execute_after_ajax();
    }
    

    in the view:

      var tbl;
      WaAjaxHelper.add_function_to_execute_after_ajax(function (){tbl.fnDraw()})
    

    where tbl stores the datatable object.

提交回复
热议问题