javascript-ej1-demos/print/methods.html

180 строки
7.0 KiB
HTML
Исходник Обычный вид История

2022-12-22 11:48:37 +03:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Essential JS 1 : Print API's</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<!--<link href="../content/bootstrap.min.css" rel="stylesheet" />-->
<link href="../content/bootstrap.min.css" rel="stylesheet" />
<link href="../content/ejthemes/default-theme/ej.web.all.min.css" rel="stylesheet" />
<link href="../content/default.css" rel="stylesheet" />
<link href="../content/default-responsive.css" rel="stylesheet" />
<link href="../content/ejthemes/responsive-css/ej.responsive.css" rel="stylesheet" />
<!--[if lt IE 9]>
<script src="../scripts/jquery-1.11.3.min.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="../scripts/jquery-3.4.1.min.js"></script>
<!--<![endif]-->
<script src="../scripts/jquery.easing.1.3.min.js"></script>
<script src="../scripts/jsondata.min.js"></script>
<script src="../scripts/jsrender.min.js"></script>
<script src="../scripts/ej.web.all.min.js"></script>
<script src="../scripts/properties.js" type="text/javascript"></script>
</head>
<body>
<div class="content-container-fluid">
<div class="row">
<div class="cols-sample-area">
<div class="control">
<div id="Grid"></div>
</div>
<br />
<br />
<div class="control2">
<b>Note</b>:Users can print the current page,particular item and all items in grid.
</div>
</div>
<div id="sampleProperties">
<div class="prop-grid">
<div class="row">
<div class="col-md-12">
<input type="checkbox" id="printglobalstyles" checked="checked" />&nbsp;&nbsp;Global styles
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="button" id="printpage">Print the current page</button>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<button class="button" id="newwindow">Print in new window</button>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<button class="button" id="Add">Print the text</button>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="button" id="virtual">Print the all items</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(function ($) {
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
columns: [
{ field: "OrderID", headerText: "Order ID", textAlign: ej.TextAlign.Right, width: 75 },
{ field: "CustomerID", headerText: "Customer ID", width: 90 },
{ field: "EmployeeID", headerText: "Employee ID", textAlign: ej.TextAlign.Right, width: 80 },
{ field: "Freight", headerText: "Freight", textAlign: ej.TextAlign.Right, width: 80 },
{ field: "ShipCity", headerText: "Ship City", width: 90 },
{ field: "Verified", headerText: "Verified", width: 90 }
]
});
$("#printglobalstyles").ejCheckBox({ "change": "onGlobalStyles" });
$("#printpage").ejButton({
size: "normal", width: "113px", height: "45px", click: "onPrintPage"
});
$("#Add").ejButton({
size: "normal", width: "113px", click: "onPrintelement"
});
$("#virtual").ejButton({
size: "normal", width: "113px", height: "45px", click: "onvirtualdata"
});
$("#newwindow").ejButton({
size: "normal", width: "113px", height: "45px", click: "onNewwindow"
});
})
function onGlobalStyles(args) {
var ele = $("#Grid");
if (args.isChecked) {
if (!ele.hasClass("e-print")) {
$("#Grid").ejPrint(
{
globalStyles: true,
});
} else {
var obj = $("#Grid").ejPrint("instance")
obj.option("globalStyles", true);
obj.print();
}
} else {
if (!ele.hasClass("e-print")) {
$("#Grid").ejPrint(
{
globalStyles: false,
});
} else {
var obj = $("#Grid").ejPrint("instance");
obj.option("globalStyles", false);
obj.print();
}
}
}
function onPrintPage(e) {
var ele = $(document.body);
if (!ele.hasClass("e-print")) {
$(document.body).ejPrint();
} else {
obj = $(document.body).ejPrint("instance");
obj.print();
}
}
function onPrintelement(e) {
var ele = $("#Grid");
if (!ele.hasClass("e-print")) {
$("#Grid").ejPrint();
var obj = $("#Grid").ejPrint("instance");
obj.print(".control2");
} else {
obj = $("#Grid").ejPrint("instance");
obj.print(".control2");
}
}
function onNewwindow(e) {
var ele = $("#Grid");
if (!ele.hasClass("e-print")) {
$("#Grid").ejPrint(
{
printInNewWindow: true
});
} else {
var obj = $("#Grid").ejPrint("instance");
obj.option("printInNewWindow", true);
obj.print();
}
}
function onvirtualdata(e) {
var ele = $("#Grid");
var gridobj = $("#Grid").ejGrid("instance");
gridobj.option('allowPaging', false);
if (!ele.hasClass("e-print")) {
$("#Grid").ejPrint();
} else {
var obj = $("#Grid").ejPrint("instance");
obj.print();
}
gridobj.option('allowPaging', true);
}
$("#sampleProperties").ejPropertiesPanel();
</script>
</body>
</html>