我的javascript和asp.net mvc打印预览有问题。 我获取搜索数据并通过JSON将数据传递给JavaScript函数:
function preview (content) (
debugger;
var result = content.get_response (). get_object ();
var json = eval (result);
var w = window.open ( 'Stampa.aspx', "Research Press", "height = 1200, width = 1000, status = yes, toolbar = no, menubar = no, location = no");
w.document.open ();
HeadPrint + = "<table border=1>";
CreateTableRicercaHead ();
CreateTableRicercaMain (JSON)
FootPrint + = "</ table>";
var node = w.document.createTextNode (HeadPrint + + strPrint Footprint);
alert (node.data);
var divPrint = w.document.getElementById (PrintDocument);
/ / divPrint.innerHTML = HeadPrint + + strPrint footprint;
divPrint.appendChild (node);
alert (divPrint.appendChild (node));
CreateTableRicercaMain function (data) (
for (var list in data.r) (
strPrint + = "<tr>";
strPrint + = "<td>";
strPrint + = data.r [list]. UserID;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Surname;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Name;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Way;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Telephone;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. common;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Cap;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Province;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. CF;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Data_Versamento;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. IdOperatore;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Amount;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Data_inserimento;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Note;
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. causal
strPrint + = "</ td>";
strPrint + = "<td>";
strPrint + = data.r [list]. Nr_CC;
strPrint + = "</ td>";
)
)
CreateTableRicercaHead function () (
HeadPrint + = "<tr>";
HeadPrint + = "<th>";
HeadPrint + = "UserID";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Name";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Name";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Street";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Phone";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "common";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Cap";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Province";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Cf";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Data_Versamento";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "IdOperatore";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Amount";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Data_inserimento";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Notes";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Cause";
HeadPrint + = "</ th>";
HeadPrint + = "<th>";
HeadPrint + = "Nr_CC";
HeadPrint + = "</ th>";
HeadPrint + = "</ tr>";
)
以及如何 你可以看到我尝试用innerHTML方法在div中写入结果,因为如果你用document.write()写它,我注意到对于一定大小(4000)的数据,显示是1分钟。 ,但问题是当我打开弹出窗口时,我不显示任何白色,如果我右键单击 - >查看HTML我没有看到任何内容。您能帮我解决这个问题吗?
答案 0 :(得分:0)
不确定为什么不在服务器端构建最适合循环的表。 JavaScript在大型循环中非常糟糕。
我的代码中没有看到w.document.close()。
答案 1 :(得分:0)
您好,感谢您的回答,同时服务器端也有一定数量的数据,页面显示速度非常慢。我的目标是通过json传递数据,将div.innerHTML设置为结果,因为如果我放在同一页面上,我会在不到1秒的时间内显示4000条记录。 然后我想打开文档,然后读取我创建页面的div,但不起作用。
然后你建议我做服务器端的一切? 感谢