Look first:
Lodop plugin needs to be installed
Print Browsing Effect:
Prerequisites for printing
Go to the official website to download a few JS packages: Http://www.lodop.net/download.html added to the project
The picture is as follows:
Add the following code to the Web front end needs to print the corresponding location of the function page
<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>
I myself encapsulated the print JS code (encapsulated in table format data)
1 functionPrn1_preview () {2 varLodop = Getlodop (document.getElementById (' Lodop_ob '), document.getElementById (' Lodop_em ')));3Lodop. Print_init ("Print control function Demo _lodop function _ Print form");4 5 varTheads = "<thead ><tr><th width= ' 300px ' > dish name </th><th width= ' 50px ' > number of copies </th><th Width= ' 50px ' > Price </th><th width= ' 150px ' > name </th><th width= ' 150px ' > Time </ Th></tr></thead> "6 varTablebodystar = "<table border= ' 1 ' >";7 varTablebodyend = "</table>";8 varTablehead = "<caption style= ' width:200px; ' > Order List </caption> "9 Ten varTablebody; One A$ (Lodopvalue). each (function () { - - varMenuname = "<tr><th width= ' 300px ' >" + This. Menu_name; the varListnumber = "</th><td width= ' 50px ' >" + This. List_number; - varClistprice = "</td><td width= ' 50px ' >" + This. Clist_price; - varEmployeeloginname = "</td><td width= ' 150px ' >" + This. Employee_loginname; - varClisttime = "</td><td width= ' 150px ' >" + times ( This. clist_time); + //alert (menuname); -Tablebody + = menuname + listnumber + clistprice + employeeloginname + clisttime + "</td></tr>"; + //alert (tablebody); A }); at - vart =Tablebodystar; -T + =Tablehead; -T + =theads; -T + =Tablebody; -T + =Tablebodyend; in -Lodop. Add_print_htm (60, 20, 800, 1000, T); to Lodop. PREVIEW (); +};
Note: The above lodopvalue is a global variable that I define, which is the data inside the DataGrid:
Onloadsuccess:function (data)
{
var rows = data.rows;
}
Lodopvalue = rows; The data printed is primarily the data in rows
Lodop Use of print controls