3 Answers, 1 is accepted
To print the grid you should use the approach demonstrated in the following code library. Note that to include all grid pages you also need to set AllowPaging="false":
http://www.telerik.com/support/code-library/print-radgrid-contents
Regards,
Pavlina
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hello All,
I used the same concept to print all data instead of only first page but in that case paging also get removed on ui which i dont want. Please help me out in that. I am stuck in this from so long.
Actual requirement:
On page load we have to bidn the grid with data with allow paging=true and when i click on print i need all data which we have in grid without paging but in ui it has to show paging.
Please find attached screenshot and below code which i am using
Javascript code:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function PrintRadGrid(radGrid)
{
setTimeout(function()
{
var previewWnd = window.open('about:blank', '', '', false);
var styleStr = "<html><head><link href='Styles.css' rel='stylesheet' type='text/css'></link></head>";
var htmlcontent = styleStr + "<body>" + $find(radGrid).get_element().outerHTML + "</body></html>";
previewWnd.document.open();
previewWnd.document.write(htmlcontent);
previewWnd.document.close();
previewWnd.print();
previewWnd.close();
}, 100);
}
</script>
</telerik:RadCodeBlock>
Server side code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
radGrid1.AllowPaging = false;
radGrid1.MasterTableView.AllowFilteringByColumn = false;
radGrid1.Rebind();
RadAjaxPanel1.ResponseScripts.Add("PrintRadGrid('" + radGrid1.ClientID + "')");
}
HTML :
<telerik:RadGrid ID="radGrid1" runat="server" Skin="Simple" DataSourceID="SqlDataSource1"
Style="margin: 20px;" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" PageSize="9"
GridLines="None">
</telerik:RadGrid>
Hello All,
I used the same concept to print all data instead of only first page but in that case paging also get removed on ui which i dont want. Please help me out in that. I am stuck in this from so long.
Actual requirement:
On page load we have to bidn the grid with data with allow paging=true and when i click on print i need all data which we have in grid without paging but in ui it has to show paging.
Please find attachedscreenshot and below sample code:
Javascript code:
<script type="text/javascript">
function PrintRadGrid(radGrid)
{
setTimeout(function()
{
var previewWnd = window.open('about:blank', '', '', false);
var styleStr = "<html><head><link href='Styles.css' rel='stylesheet' type='text/css'></link></head>";
var htmlcontent = styleStr + "<body>" + $find(radGrid).get_element().outerHTML + "</body></html>";
previewWnd.document.open();
previewWnd.document.write(htmlcontent);
previewWnd.document.close();
previewWnd.print();
previewWnd.close();
}, 100);
}
</script>
Server code:
protected void LinkButton1_Click(object sender, EventArgs e)
{
radGrid1.AllowPaging = false;
radGrid1.MasterTableView.AllowFilteringByColumn = false;
radGrid1.Rebind();
RadAjaxPanel1.ResponseScripts.Add("PrintRadGrid('" + radGrid1.ClientID + "')");
}
HTML:
<telerik:RadGrid ID="radGrid1" runat="server" Skin="Simple" DataSourceID="SqlDataSource1"
Style="margin: 20px;" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" PageSize="9"
GridLines="None">
</telerik:RadGrid>