Printing Editform content only

6 posts, 0 answers
  1. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2013 Link to this post

    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
  2. Steve Lassanske
    Steve Lassanske avatar
    5 posts
    Member since:
    Sep 2007

    Posted 20 Nov 2013 Link to this post

    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;
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 21 Nov 2013 Link to this post

    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. 
  5. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 25 Nov 2013 Link to this post

    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.
  6. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 25 Nov 2013 Link to this post

    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.
  7. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 28 Nov 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017