Hi Asutosh,
You can include all the Grids in the print button click event access each grid and set its properties which are necessary. Please check the code snippet:
JS:
function
PrintRadGrid() {
//Access all the Grids
var
radGrid1 = $find(
'<%= RadGrid1.ClientID %>'
);
var
radGrid2 = $find(
'<%= RadGrid2.ClientID %>'
);
var
previewWindow = window.open(
'about:blank'
,
''
,
''
,
false
);
var
styleSheet =
'<%= Telerik.Web.SkinRegistrar.GetWebResourceUrl(this, RadGrid1.GetType(), String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css", RadGrid1.Skin)) %>'
;
var
baseStyleSheet =
'<%= Telerik.Web.SkinRegistrar.GetWebResourceUrl(this, RadGrid1.GetType(), "Telerik.Web.UI.Skins.Grid.css") %>'
;
var
htmlContent =
"<html><head><link href = '"
+ styleSheet +
"' rel='stylesheet' type='text/css'></link>"
;
htmlContent +=
"<link href = '"
+ baseStyleSheet +
"' rel='stylesheet' type='text/css'></link></head>"
;
//Add the contents of each Grid
htmlContent = htmlContent +
"<body>"
+ getOuterHTML(radGrid1.get_element()) +
"</body></html>"
;
htmlContent = htmlContent +
"<body>"
+ getOuterHTML(radGrid2.get_element()) +
"</body></html>"
;
previewWindow.document.open();
previewWindow.document.write(htmlContent);
previewWindow.document.close();
previewWindow.print();
if
(!$telerik.isChrome) {
previewWindow.close();
}
}
C#:
//Print button click
protected
void
LinkButton2_Click(
object
sender, EventArgs e)
{
//Set properties for first grid
RadGrid1.MasterTableView.HierarchyDefaultExpanded =
true
;
RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded =
true
;
RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
RadGrid1.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;
RadGrid1.AllowPaging =
false
;
RadGrid1.Rebind();
//Set properties for second grid
RadGrid2.MasterTableView.HierarchyDefaultExpanded =
true
;
RadGrid2.MasterTableView.DetailTables[0].HierarchyDefaultExpanded =
true
;
RadGrid2.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
RadGrid2.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;
RadGrid2.AllowPaging =
false
;
RadGrid2.Rebind();
HiddenField1.Value =
"true"
;
}
Thanks,
Shinu