Hello all...
I would like to use the following JavaScript to print the contents of a details table.
This works just fine for the first details results.
I would like to change this to the following.
And in the serverside code the following
How do I get the detailTable ID so I can add it to the print button? Thanks.
I would like to use the following JavaScript to print the contents of a details table.
| 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 detailTable = $find('<%= radGrid1.ClientID %>').get_detailTables()[0]; |
| var htmlcontent = styleStr + "<body><div class='RadGrid RadGrid_Simple'>" + detailTable.get_element().outerHTML + "</div></body></html>"; |
| previewWnd.document.open(); |
| previewWnd.document.write(htmlcontent); |
| previewWnd.document.close(); |
| previewWnd.print(); |
| } |
I would like to change this to the following.
| function PrintRadGrid(detailsID) |
| { |
| 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 detailTable = $find('<%= radGrid1.ClientID %>').get_detailTables()[detailsID]; |
| var htmlcontent = styleStr + "<body><div class='RadGrid RadGrid_Simple'>" + detailTable.get_element().outerHTML + "</div></body></html>"; |
| previewWnd.document.open(); |
| previewWnd.document.write(htmlcontent); |
| previewWnd.document.close(); |
| previewWnd.print(); |
| } |
| Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound |
| If TypeOf e.Item Is GridDataItem Then |
| Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
| If Not (e.Item.OwnerTableView.DataSourceID = "SqlDataSource2") Then |
| dim detailsID as integer = ??? 'How do I get the details id? |
| Dim ImagePrintButton As ImageButton = DirectCast(dataItem("ImagePrintCol").FindControl("ImagePrint"), ImageButton) |
| ImagePrintButton.Attributes.Add("onclick", "PrintRadGrid('" & detailsID & "'");return false;") |
| End If |
| End If |
| End Sub |