gpt4 book ai didi

javascript - 仅打印农业网格数据而无需分页或任何其他内容的有效方法

转载 作者:行者123 更新时间:2023-11-28 03:07:02 24 4
gpt4 key购买 nike

我试图仅打印ag-grid数据,例如Data-Table print中的打印按钮

1-我尝试了 ngx-print 但它不适用于 Angular 8。

2-我尝试了ag-grid-Example的官方方式但我认为这在打印时显示分页和其他页面内容也不是一种有效的方法。

我试过print-This按照以下步骤使用 Angular 插件:

1- 通过 npm 安装它2-调用节点 angular.json 内的 .js 文件(包含您要在系统中使用的所有插件的文件)但它仍然无法将 .printThis() 识别为函数。

我不知道如何在没有页面其他内容的情况下打印唯一的ag-grid数据,为什么ag-grid没有内置功能,例如DataTable插件?!!!

最佳答案

2- I tried the official way from ag-grid-Example But I think it's not an efficient way also its show pagination and another page content when you print.

但这已经是打印所有数据的有效且预期的方式(无需网格分页)。

如果您想隐藏其他内容(无法意识到没有页面的其他内容是什么意思) - 则需要预先渲染此内容数据(或至少为浏览器打印方法做好准备)

UPDATE

I checked datatable solution, and basically its exactly as I said, they just prepared function which is making datatable content on new window to isolate from everything else and then execute print() method.

这是一个part of their code (仅供理解):

// Construct a table for printing
var html = '<table class="'+dt.table().node().className+'">';

if ( config.header ) {
html += '<thead>'+ addRow( data.header, 'th' ) +'</thead>';
}

html += '<tbody>';
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
html += addRow( data.body[i], 'td' );
}
html += '</tbody>';

if ( config.footer && data.footer ) {
html += '<tfoot>'+ addRow( data.footer, 'th' ) +'</tfoot>';
}
html += '</table>';

...

// Allow stylesheets time to load
var autoPrint = function () {
if ( config.autoPrint ) {
win.print(); // blocking - so close will not
win.close(); // execute until this is done
}
};

此外,我尝试使用隐藏元素,这也是可能的,但这样就需要关心可见性和覆盖。

关于javascript - 仅打印农业网格数据而无需分页或任何其他内容的有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60527897/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com