简体   繁体   English

使用javascript打印时,如果页面中断时如何添加标题?

[英]how to add header when page breaks when print using javascript?

i have a Grid which contains more than 100 records at every time.When i am trying to print the data using javascript. 我有一个网格,每次包含100多个记录。当我尝试使用javascript打印数据时。 It able to print the grid data.But my problem is to be in every page not having the page header and at the sametime the final record data is missing .i need to fix this issue anyone help me to improve 它能够打印网格数据。但是我的问题是每个页面都没有页面标题,但同时缺少最终记录数据。我需要解决此问题,任何人都可以帮助我改善

 self.print();

i am using this command for initiate print.after that 我正在使用此命令进行初始化打印。

var gridid = "#grid";
    $("#pageheader").show();
    $("#pageheader").clone().addClass("clonecopy").appendTo("body");
    $(gridid).clone().addClass("clonecopy").appendTo("body");`

By this coding used for print only my Grid in print screen. 通过此编码用于仅在打印屏幕上打印我的网格。 在此处输入图片说明

and i need to fix this by 15 records per page and headers(for every page) 我需要通过每页15个记录和页眉(每页)来解决此问题

 function printControl(){

        var table = document.getElementById("DataList1");
        var count = table.rows.length;
        for (var i = 0; i < count; i++) {
            if ((i % 4 == 0)&&(i!=0)) {
                table.rows[i].style.cssText = "page-break-after:always";
            }
        }
    }

and also i am using this code but i cant get the result.. 而且我正在使用此代码,但我无法得到结果..

Making a few assumptions here, but it would look similar to below: 在这里做一些假设,但是看起来与下面类似:

var count = 0;
var page = $('<div></div>');
$('#grid').children().each(function(){
    if( count == 0 ){
        $("#pageheader").clone().addClass("clonecopy").appendTo(page);
    }
    $(this).clone().addClass("clonecopy").appendTo(page);
    count += 1;
    if( count == 15 ){
        page.appendTo("body");
        page = $('<div></div>');
        count = 0;
    } 
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用page-break-inside时,在分页符时添加标题:避免使用CSS或JavaScript还是从浏览器中删除? - add header when page breaks when using page-break-inside: avoid wth css or javascript or from browser? 我要打印页面时javascript中断 - javascript breaks when I want to print a page 使用javascript和jQuery重新加载页面时如何添加颜色 - How to add colours when a page is reloaded using javascript and jQuery 当我添加图形标题时,反应性汉堡包菜单中断 - Reactive Hamburger Menu breaks when I add Graphical Header 在PHP中使用标头功能时,页面未更改,但可与Javascript一起使用 - Page not changing when using header function in PHP but works with Javascript 尝试使用javascript打印页面时出现错误请求 - bad request when trying to print a page using javascript 如何在打印时使用 JavaScript 或 CSS 在页脚中添加页码? - How to add page number in footer using JavaScript or CSS while print? 当我们使用javascript单击垂直选项卡时,如何显示页面标题和菜单 - How to show page header and menu, when we click on the vertical tab using javascript 如何使用Java脚本在HTML中添加换行符 - How to add line breaks into HTML using Javascript 当打印页面出现在javascript中时,如何删除“日期”和“无标题”字母? - How to remove 'Date' and 'Untitled' letters when print page appears in javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM