zoukankan      html  css  js  c++  java
  • lodop 打印控件的使用

    先看效果图 :

    lodop插件  需要安装

           

      打印浏览效果:

    实现打印的前提条件

    去官网下载几个js包 : http://www.lodop.net/download.html 添加到项目中

    图片如下:

    把下面这段代码加入到 web 前端需要打印功能页的相应位置

    <script language="javascript" src="LodopFuncs.js"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>

    我自己封装的打印js代码(封装成 table 格式的数据 )

     1     function prn1_preview() {
     2         var LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
     3         LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_打印表格");
     4        
     5         var theads = "<thead ><tr><th width='300px'>菜名</th><th width='50px'>份数</th><th width='50px'>价格</th><th width='150px'>姓名</th><th                          width='150px'>时间</th></tr></thead>"
     6         var tableBodyStar = "<table border='1'>";
     7         var tableBodyEnd = "</table>";
     8         var tableHead = "<caption style='200px;'>点餐列表</caption>"
     9 
    10         var tableBody;
    11      
    12         $(LodopValue).each(function () {
    13 
    14             var menuname = "<tr><th width='300px'>" + this.menu_name;
    15             var listnumber = "</th><td width='50px'>" + this.list_number;
    16             var clistprice = "</td><td width='50px'>" + this.clist_price;
    17             var employeeloginName = "</td><td width='150px'>" + this.employee_loginName;
    18             var clisttime = "</td><td width='150px'>" + timeS(this.clist_time);
    19          //   alert(menuname);
    20           tableBody += menuname + listnumber + clistprice + employeeloginName + clisttime + "</td></tr>";
    21           //  alert(tableBody);
    22         });
    23 
    24       var t = tableBodyStar;
    25         t += tableHead;
    26         t += theads;
    27         t += tableBody;
    28         t += tableBodyEnd;
    29 
    30         LODOP.ADD_PRINT_HTM(60, 20, 800, 1000, t );   
    31         LODOP.PREVIEW();
    32     };

     注意: 上面的 LodopValue 是我定义的一个全局变量,是datagrid 里面的数据  :

    onLoadSuccess: function (data)

    {
         var rows = data.rows;

    }

        LodopValue = rows; //  打印的数据主要是 rows中的数据 

  • 相关阅读:
    CodeForces 710CMagic Odd Square(经典-奇数个奇数&偶数个偶数)
    CodeForces 710A King Moves(水题-越界问题)
    CodeForces 701C They Are Everywhere (滑动窗口)
    CodeForces 701B Cells Not Under Attack
    [补档]happiness
    [补档]王者之剑
    [补档]士兵占领
    [补档]搭配飞行员
    [补档]暑假集训D6总结
    [补档][Lydsy2017年4月月赛]抵制克苏恩
  • 原文地址:https://www.cnblogs.com/izhiniao/p/4160117.html
Copyright © 2011-2022 走看看