datatables jquery" bserverside":真正的重载问题

时间:2016-11-02 12:31:54

标签: javascript jquery datatables

无论如何,重绘时显示服务器端数据表(v 1.9)是否会重新加载(显示/隐藏列,更新)? 无论如何要指定只有在" sSearch"时才会重新加载表格。或" iDisplayLength"更改,或更改页面?

这是代码:

tbl_ProductSales = $("#tblProductSales").dataTable({
        //"sAjaxSource": "Handlers/HandlerProductPurchases.ashx?op=getSales&Filter=ThisMonth",
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "/Handlers/HandlerProductPurchases.ashx",
        "fnServerParams": function (aoData) {
            aoData.push(
                {
                    "name": "Filter",
                    "value": ($("input:radio[name='DateProductSales']:checked").val() != undefined) ? $("input:radio[name='DateProductSales']:checked").val() : "getDate"//$("input:radio[name='DateProductSales']:checked").val()
                },
                {
                    "name": "StartDate",
                    "value": ($("#startdateProductSales").val().length > 1) ? $("#startdateProductSales").val() : "undefined"
                },
                {
                    "name": "EndDate",
                    "value": ($("#enddateProductSales").val().length > 1) ? $("#enddateProductSales").val() : "undefined"
                }
                );
        },
        "order": [[9, "desc"]],

        "fnDrawCallback": function () {
            setTimeout(function () { tableResponsive(); }, 500);
        },
        "initComplete": function () {

            var addShowHideBTN = '<button class="btn btn-default btn-hide m-l-10" type="button">Minimise</button>';

            if ($("#tblProductSales_length").parent().children().length == 1)
                $("#tblProductSales_length").parent().append(addShowHideBTN);

            $("#tblProductSales_wrapper .btn-hide").live('click', function () {
                //tbl_ProductSales.fnSetColumnVis(0, false);
                //tbl_ProductSales.fnSetColumnVis(3, false);
                //tbl_ProductSales.fnSetColumnVis(4, false);
                //tbl_ProductSales.fnSetColumnVis(5, false);
                //tbl_ProductSales.width("100%");
                $(this).removeClass("btn-hide");
                $(this).text("Maximise");
                $(this).addClass("btn-show");
            });
            $("#tblProductSales_wrapper .btn-show").live('click', function () {
                //tbl_ProductSales.fnSetColumnVis(0, true);
                //tbl_ProductSales.fnSetColumnVis(3, true);
                //tbl_ProductSales.fnSetColumnVis(4, true);
                //tbl_ProductSales.fnSetColumnVis(5, true);
                //tbl_ProductSales.width("120%");
                $(this).removeClass("btn-show");
                $(this).text("Minimise");
                $(this).addClass("btn-hide");
            });
        }
    });

0 个答案:

没有答案