Ciao a tutti,ho un problema con la visualizzazione della stampa che io implemento con json e javascript aprendo il popup e visualizzando i dati.
Il problema è che cliccando una volta su stampa mi visualizza i dati corretti,una seconda volta me li ripete e io stavo provando a svuotare il div che mi contiene i dati ma niente non riesco.
Questo è il codice completo:
codice:
function AnteprimaRicerca(content) {
var result = content.get_response().get_object();
var json = eval(result);
var win = window.open('', 'Stampa', 'width=500,height=500, status = no, toolbar = no, menubar = no, location = no,scrollbars=yes');
win.document.body.innerHTML = [
"<div id=\"printdocument\"></div>"
].join('');
var div = win.document.getElementById('printdocument');
div.appendChild("");
CreateTableRicercaHead();
CreateTableRicercaMain(json);
FootPrint += "</table>";
win.document.getElementById('printdocument').innerHTML = HeadPrint + strPrint + FootPrint;
win.document.close();
}
function CreateTableRicercaMain(data) {
$.each(data.r, function(i, item) {
strPrint += "<tr>";
strPrint += "<td>";
strPrint += item.IdUtente;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Cognome;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Nome;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Via;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Telefono;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Comune;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Cap;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Provincia;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Cf;
strPrint += "</td>";
strPrint += "<td>";
strPrint += $D(item.Data_Versamento).strftime('%d/%m/%Y');
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.IdOperatore;
strPrint += "</td>";
strPrint += "<td>";
strPrint += "€ " + item.Importo;
strPrint += "</td>";
strPrint += "<td>";
strPrint += $D(item.Data_inserimento).strftime('%d/%m/%Y');
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Note;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Causale;
strPrint += "</td>";
strPrint += "<td>";
strPrint += item.Nr_CC;
strPrint += "</td>";
});
}
function CreateTableRicercaHead() {
HeadPrint += "<div id='btnprint'>";
HeadPrint += "<input type='button' value=\"conferma\" id='print' onclick=\"document.getElementById('btnprint').style.display='none';window.print();window.close();\";>";
HeadPrint += "</div>";
HeadPrint += "<table border=1>";
HeadPrint += "<tr>";
HeadPrint += "<th>";
HeadPrint += "IdUtenti";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Cognome";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Nome";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Via";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Telefono";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Comune";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Cap";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Provincia";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Cf";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Data_Versamento";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "IdOperatore";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Importo";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Data_inserimento";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Note";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Causale";
HeadPrint += "</th>";
HeadPrint += "<th>";
HeadPrint += "Nr_CC";
HeadPrint += "</th>";
HeadPrint += "</tr>";
}
Spero che mi possiate aiutare, non so come devo gestirla!
Grazie di tutto