
Kendo UI目前最新提供Kendo UI for jQuery、Kendo UI for Angular、Kendo UI Support for React和Kendo UI Support for Vue四個(gè)控件。Kendo UI for jQuery是創(chuàng)建現(xiàn)代Web應(yīng)用程序的完整UI庫。
打印
即使Grid的內(nèi)容可能不是頁面上的唯一內(nèi)容,Grid也提供忽略頁面其余部分并僅打印其內(nèi)容的選項(xiàng)。
要僅從頁面上打印Grid,請(qǐng)使用以下兩種方法:
打印現(xiàn)有頁面,并使用打印CSS隱藏不相關(guān)的內(nèi)容。
打印僅帶有Grid的單獨(dú)網(wǎng)頁。
打印現(xiàn)有網(wǎng)頁
若要僅將Grid作為現(xiàn)有網(wǎng)頁的一部分進(jìn)行打印,請(qǐng)使用打印樣式表隱藏頁面中不需要的部分,確切的CSS打印取決于現(xiàn)有頁面內(nèi)容。
打印新網(wǎng)頁
下面的示例演示如何檢索Grid的HTML,如何將其注入到新的瀏覽器窗口中以及打印新頁面。此方法還解決了以下重要問題:
function printGrid() {
var gridElement = $(‘#grid’),
printableContent = ”,
win = window.open(”, ”, ‘width=800, height=500, resizable=1, scrollbars=1’),
doc = win.document.open();
var htmlStart =
‘’ +
‘
’ +
‘’ +
‘’ +
‘
’ +
‘
‘ +
‘
’ +
‘’ +
‘
var htmlEnd =
‘’ +
‘’;
var gridHeader = gridElement.children(‘.k-grid-header’);
if (gridHeader[0]) {
var thead = gridHeader.find(‘thead’).clone().addClass(‘k-grid-header’);
printableContent = gridElement
.clone()
.children(‘.k-grid-header’).remove()
.end()
.children(‘.k-grid-content’)
.find(‘table’)
.first()
.children(‘tbody’).before(thead)
.end()
.end()
.end()
.end()[0].outerHTML;
} else {
printableContent = gridElement.clone()[0].outerHTML;
}
doc.write(htmlStart + printableContent +htmlEnd);
doc.close();
win.print();
}
$(function () {
var grid = $(‘#grid’).kendoGrid({
dataSource: {
type: ‘odata’,
transport: {
read: “https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products”
},
pageSize: 20,
serverPaging: true,
serverSorting: true,
serverFiltering: true
},
toolbar: kendo.template($(‘#toolbar-template’).html()),
height: 400,
pageable: true,
columns: [
{ field: ‘ProductID’, title: ‘Product ID’, width: 100 },
{ field: ‘ProductName’, title: ‘Product Name’ },
{ field: ‘UnitPrice’, title: ‘Unit Price’, width: 100 },
{ field: ‘QuantityPerUnit’, title: ‘Quantity Per Unit’ }
]
});
$(‘#printGrid’).click(function () {
printGrid();
});
});
京ICP備09015132號(hào)-996 | 違法和不良信息舉報(bào)電話:4006561155
© Copyright 2000-2026 北京哲想軟件有限公司版權(quán)所有 | 地址:北京市海淀區(qū)西三環(huán)北路50號(hào)豪柏大廈C2座11層1105室
北京哲想軟件集團(tuán)旗下網(wǎng)站:哲想軟件 | 哲想動(dòng)畫