这是代码:
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");
});
}
});