PDA

View Full Version : چطور میشه گرید ویو رو راست به چپ پرینت گرفت؟



sibooy
سه شنبه 08 اسفند 1396, 11:31 صبح
سلام من یه گرید ویو دارم که داخل یک printpanle قرار داره.

<div runat="server" style="height: 400px; width:800px; overflow: scroll">
<asp:Panel id="pnlContents" runat = "server" Direction="RightToLeft">
<asp:GridView ID="fedList" runat="server" AutoGenerateColumns="false" CssClass="parastoo" OnRowDataBound="MatchList_RowDataBound" Direction="RightToLeft">
<Columns>
<asp:BoundField HeaderText="کد ملی" DataField="ID" />
<asp:BoundField HeaderText="نام" DataField="name" />
<asp:BoundField HeaderText="نام خانوادگی" DataField="family" />
<asp:BoundField HeaderText="نام پدر" DataField="father_name" />
<asp:BoundField HeaderText="تولد" DataField="birthday" />
<asp:BoundField HeaderText="جنسیت" DataField="sex" />
<asp:BoundField HeaderText="مدرک تحصیلی" DataField="diploma" />
<asp:BoundField HeaderText="استان" DataField="state" />
<asp:BoundField HeaderText="شهر" DataField="city" />
<asp:BoundField HeaderText="تلفن" DataField="tel" />
</Columns>
</asp:GridView>
</asp:Panel>
</div>



و یک دکمه برای پرینت


<asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick = "return PrintPanel();" />

و این اسکریپت برای پرینت گرفتن از محتویات printpanel

<script type = "text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>فهرست ورزشکاران، مرشدان، مربیان، مدرسان و داوران</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);

printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>


مشکل بزرگ من اینه که موقع چاپ ستون ها چپ به راست قرار میگریه. اما من میخوام راست به چپ چاپ بشه. کسی می تونه کمکم کنه؟

sibooy
چهارشنبه 09 اسفند 1396, 08:21 صبح
خدا حامی جوینده هاس. خودم پیدا کردم
توی بخش اسکریپت این خط کد رو اضافه می کنیم. اون وقت درست میشه. پرینتمون راس به چپ میشه

printWindow.document.dir = "rtl";


اسکریپتمون این ریختی میشه درواقع

<script type = "text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>عنوان صفحه پرینت</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.dir = "rtl";
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>