This is a migrated thread and some comments may be shown as answers.

Printing Editform content only

5 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vijaianand
Top achievements
Rank 1
Vijaianand asked on 20 Nov 2013, 03:42 PM
Hi

I been trying to find options to just print the editform content. I have grid with usercontrol editform which is almost a page size and user might want to print the form content only for discussion purposes. I know there are print options which we can try to print the screen but it looks ugly with grid on the background. I am trying to see whether there is any option just to print the edit form content only with form format not in excel format. 

Vijai

5 Answers, 1 is accepted

Sort by
0
Steve Lassanske
Top achievements
Rank 1
answered on 20 Nov 2013, 08:21 PM
I don't know if this gives you what you want, but you can gather the values of controls within panel that's within an editform, and then print them anyway that you choose.

Here's an example of a grid's edit form. All controls within it are inside a panel container.
<EditFormSettings EditFormType="Template">
    <FormTemplate>
        <asp:Panel ID="pnlEditForm" runat="server">
            <table>
                <tr>
                    <td>
                        <telerik:RadTextBox ID="txtEditText" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <telerik:RadButton ID="btnPrintEdit" runat="server" OnClick="btnPrintEdit_Click" Text="Print" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </FormTemplate>
</EditFormSettings>
 
In the Print button's click event, it casts the sender as a RadButton and gets it's parent container, which is a panel. We then get the panel's container which is a GridEditFormItem (without the panel, you can probably get the parent of the button's GridEditFormItem). From there, you can do a FindControl on the GridEditFormItem to get any control inside of the GridEditFormItem and assemble then for printing.
protected void btnPrintEdit_Click(object sender, EventArgs e)
{
    RadButton btnPrintEdit = (sender as RadButton);
    Panel myPanel = btnPrintEdit.Parent as Panel;
    GridEditFormItem dataItem = myPanel.NamingContainer as GridEditFormItem;
    RadTextBox EditText = (RadTextBox)dataItem.FindControl("txtEditText") as RadTextBox;
}
0
Vijaianand
Top achievements
Rank 1
answered on 21 Nov 2013, 09:16 PM
No, that's not what I want. I can get the content of the usercontrol. I want the printscreen of the editform not the contents. I know you can print screen the radgrid by taking its content using the clientside javascript code but is it possible to only get the editform popup without underlying grid. 
0
Kostadin
Telerik team
answered on 25 Nov 2013, 08:12 AM
Hello Vijaianand,

In order to export only the edit form you have to hide all the item before exporting the grid. For this purpose you have to loop through all GridDataItems and set their Visible property to false. I prepared a small sample and attached it to this thread.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Vijaianand
Top achievements
Rank 1
answered on 25 Nov 2013, 04:40 PM
I want to print the edit form when you are inthe edit form not export. Your sample shows a button on the grid which make the ragrid items invisible and exports. It's not doable from editform usercontrol. See the attachment. There is a print button in the form, when you click you need to only show preview of that form and print it from clientside. I can only get the editform with the background grid like another attachment attached.
0
Kostadin
Telerik team
answered on 28 Nov 2013, 10:00 AM
Hello Vijaianand,

You could use the following code library in order to achieve your requirement. The example demonstrates how to print the grid but by using the same approach you could print only the edit form. I prepared a small sample which demonstrates how to achieve that. 

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Vijaianand
Top achievements
Rank 1
Answers by
Steve Lassanske
Top achievements
Rank 1
Vijaianand
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or