如何在Oracle APEX5中打印PLSql动态内容的特定部分?

时间:2017-02-06 17:51:41

标签: javascript oracle oracle-apex oracle-apex-5

我尝试过以下代码,但整个页面显示的是空白内容 1)HTML身体属性的粘贴

<script language="JavaScript">
function printPage() {
if(document.all) {
document.all.divButtons.style.visibility = 'hidden';
window.print();
document.all.divButtons.style.visibility = 'visible';
} else {
document.getElementById('divButtons').style.visibility = 'hidden';
window.print();
document.getElementById('divButtons').style.visibility = 'visible';
}
}
</script>

2)htp.p('<div id="divButtons" name="divButtons">' ); htp.p('</div>' );
3)htp.p('<input type="button" value = "Print" onclick="printPage()" style="font:bold 11px verdana;color:#FF0000;background-color:#FFFFFF;">' );

这里有PLSQL动态内容代码:::

DECLARE       
CURSOR order_list IS    
SELECT m.item_name, a.order_quantity,a.price    
FROM  add_payment a,menu_item m
where order_id=61
and
m.m_id=a.m_id; 
begin

htp.p('<div class="row">' ); 
        htp.p('<div class="col-md-12">' ); 
            htp.p('<div class="panel panel-default">' ); 
                htp.p('<div class="panel-heading">' ); 
                    htp.p('<h3 class="text-center">' ); 
                    htp.p('<strong>Order Summary');
                    htp.p('</strong>' ); 
                    htp.p('</h3>' ); 
                htp.p('</div>' ); 
                htp.p('<div class="panel-body">'); 
                    htp.p('<div class="table-responsive">'); 
                htp.p('<div id="divButtons" name="divButtons">' ); 

                        htp.p('<table class="table table-condensed">' ); 
                            htp.p('<thead>' ); 
                                htp.p('<tr>' ); 
                                htp.p('<td>' ); 
                                    htp.p('<strong>Item Name');
                                    htp.p('</strong>');
                                    htp.p('</td>');
                                    htp.p('<td class="text-center">');
                                    htp.p('<strong>Item Price');
                                    htp.p('</strong>');
                                    htp.p('</td>');
                                    htp.p('<td class="text-center">');
                                    htp.p('<strong>Item Quantity');
                                    htp.p('</strong>');
                                    htp.p('</td>');
                                    htp.p('<td class="text-right">');
                                    htp.p('<strong>Total');
                                    htp.p('</strong>');
                                    htp.p('</td>');    

                                htp.p('</tr>' ); 

                            htp.p('</thead>' ); 
                            htp.p('<tbody>' ); 
                            FOR a IN order_list LOOP 
                                htp.p('<tr>' ); 
                                    htp.p('<td>'||a.item_name||''); 
                                    htp.p('</td>' ); 
                                    htp.p('<td class="text-center">'||a.order_quantity||''); 
                                    htp.p('</td>' ); 
                                    htp.p('<td class="text-center">'||a.price||'' ); 
                                    htp.p('</td>' ); 
                                    htp.p('<td class="text-right">'||a.order_quantity*a.price||' Tk' ); 
                                    htp.p('</td>' ); 
                                htp.p('</tr>' ); 
                                END LOOP;

                                htp.p('<tr>' ); 
                                    htp.p('<td class="highrow">' ); 
                                    htp.p('</td>');
                                    htp.p('<td class="highrow">');
                                    htp.p('</td>');
                                    htp.p('<td class="highrow text-center">');
                                    htp.p('<strong>Subtotal');
                                    htp.p('</strong>');
                                    htp.p('</td>'); 
                                    htp.p('<td class="highrow text-right">$958.00');
                                    htp.p('</td>'); 
                                htp.p('</tr>'); 
                                htp.p('<tr>'); 
                                    htp.p('<td class="emptyrow">'); 
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow">'); 
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow text-center">'); 
                                    htp.p('<strong>Shipping');
                                    htp.p('</strong>'); 
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow text-right">$20');
                                    htp.p('</td>'); 
                                htp.p('</tr>'); 
                                htp.p('<tr>'); 
                                    htp.p('<td class="emptyrow">'); 
                                    htp.p('<i class="fa fa-barcode iconbig">'); 
                                    htp.p('</i>'); 
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow">'); 
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow text-center">'); 
                                    htp.p('<strong>Total');
                                    htp.p('</strong>');
                                    htp.p('</td>'); 
                                    htp.p('<td class="emptyrow text-right">$978.00');
                                    htp.p('</td>'); 
                                htp.p('</tr>'); 
                            htp.p('</tbody>'); 
                        htp.p('</table>' ); 
                    htp.p('</div>' ); 
                htp.p('</div>' ); 
            htp.p('</div>' ); 
        htp.p('</div>' ); 

    htp.p('</div>' ); 

 htp.p('</div>' ); 
  htp.p('<input type="button" value = "Print" onclick="printPage()" style="font:bold 11px verdana;color:#FF0000;background-color:#FFFFFF;">' ); 
end;

但是当点击按钮时,空白内容如下图所示:: before click print button

problem after click

1 个答案:

答案 0 :(得分:0)

看起来你真的不顾一切,并手动编写很多开箱即用的东西。

关于您的打印,您可能对此方法感兴趣

http://www.grassroots-oracle.com/2014/07/apex-printer-friendly-pages-with-css-media-queries.html