4 Answers, 1 is accepted
There is a code-library dedicated on this subject:
Print RadGrid contents
Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The original question was how to print the radgrid contents and not how to print an exported file. Here is why the aforementioned link will not be suitable for your requirements. That said, printing PDF files is out of the scope of RadGrid control.
Best regards,
Daniel
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
Dear,
I'm trying to use this java script but it seems it is not working with me. the grid is placed in side a table.
could you please help
regards,
<script type="text/javascript">
function getOuterHTML(obj)
{
if (typeof (obj.outerHTML) == "undefined")
{
var divWrapper = document.createElement("div");
var copyOb = obj.cloneNode(true);
divWrapper.appendChild(copyOb);
return divWrapper.innerHTML
}
else
return obj.outerHTML;
}
function PrintRadGrid()
{
var previewWnd = window.open('about:blank', '', '', false);
var sh = '<%= ClientScript.GetWebResourceUrl(radGrid1.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",radGrid1.Skin)) %>';
var styleStr = "<html><head><link href = '" + sh + "' rel='stylesheet' type='text/css'></link></head>";
var htmlcontent = styleStr + "<body>" + $find('<%= radGrid1.ClientID %>').get_element().outerHTML + "</body></html>";
previewWnd.document.open();
previewWnd.document.write(htmlcontent);
previewWnd.document.close();
previewWnd.print();
previewWnd.close();
}
</script>
.
.
.
.
.
.<telerik:RadGrid ID="radGrid1" runat="server" GridLines="None" Skin="Office2007"
Width="800px" DataSourceID="SqlDataSource1">
<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridBoundColumn DataField="Organization"
DefaultInsertValue="" HeaderText="Organization" SortExpression="Organization"
UniqueName="Organization" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Governorate"
DefaultInsertValue="" HeaderText="Governorate" SortExpression="Governorate"
UniqueName="Governorate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Num. of Projects" DefaultInsertValue=""
HeaderText="Num. of Projects" SortExpression="Num. of Projects"
UniqueName="Num. of Projects" DataType="System.Int32">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
..
.
.
.
..
<asp:ImageButton ID="ImageButton3" runat="server"
ImageUrl="~/images/Main/Print.png" ToolTip="Cancel" CssClass="style2" OnClientClick="PrintRadGrid(); return false;"/>