Rad Editor: How to Export Selected Row to PDF of Template Column.

4 posts, 0 answers
  1. gc_0620
    gc_0620 avatar
    246 posts
    Member since:
    Feb 2008

    Posted 18 Oct 2012 Link to this post


    Folks,

    Using VS 2010 with RadControls for ASP.NET AJAX Q3 2012. I am using below link as a prototype.

    http://demos.telerik.com/aspnet-ajax/editor/examples/edittemplate/defaultcs.aspx

    Attached is my Grid and I would like export only the Selected Row Rad Editor content to PDF in i a new window.  below is is my complete radgrid declaration.

    Any help is appreciated.

    Thanks

    gc_0620

    ______________
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
        <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
            EnableRoundedCorners="false" />
        <telerik:RadGrid ID="MyDataGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
            AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            AutoGenerateEditColumn="True" AutoGenerateDeleteColumn="True" CellSpacing="0"
            GridLines="None" AllowFilteringByColumn="True" AllowSorting="True">
            <ClientSettings>
                <Selecting AllowRowSelect="True" />
            </ClientSettings>
            <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                </RowIndicatorColumn>
                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn UniqueName="ID" Display="false">
                        <ItemTemplate>
                            <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Content">
                        <ItemTemplate>
                            <asp:Label ID="lblField1" CssClass="text" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadEditor ID="RadEditorEdit" SkinID="DefaultSetOfTools" ContentFilters="DefaultFilters,PdfExportFilter"
                                runat="server" content='<%# Bind("Content") %>'>
                                <ExportSettings OpenInNewWindow="true">
                                </ExportSettings>
                            </telerik:RadEditor>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadEditor ID="RadEditorEdit" runat="server" SkinID="DefaultSetOfTools" ContentFilters="DefaultFilters,PdfExportFilter"
                                content='<%# Bind("Content") %>'>
                                <ExportSettings OpenInNewWindow="true">
                                </ExportSettings>
                            </telerik:RadEditor>
                        </InsertItemTemplate>
                    </telerik:GridTemplateColumn>
     
                    <telerik:GridTemplateColumn UniqueName="Export">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" OnClick="Button1_Click" runat="server" Text="PDF Export"></asp:LinkButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                     
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString2 %>"
            SelectCommand="SELECT [ID], [Content] FROM [BlogPosts]" UpdateCommand="UPDATE [BlogPosts] SET [Content] = @Content WHERE [ID] = @ID"
            DeleteCommand="DELETE FROM [BlogPosts] WHERE [ID] = @ID" InsertCommand="INSERT INTO [BlogPosts] ([PublishDate], [Category], [Title], [Content]) VALUES (GETDATE(), 'Foo', 'Bar',@Content)">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Content" Type="String"></asp:Parameter>
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Content" Type="String"></asp:Parameter>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>
        </form>

  2. Rumen
    Admin
    Rumen avatar
    14467 posts

    Posted 23 Oct 2012 Link to this post

    Hello,

    You should be able to export the RadEditor's content only when the editor is enabled. You need to add an external button in the EditItemTemplate of RadGrid, which will perform postback and will fire the RadEditor1.ExportToPdf(); method when clicked as shown in the following demo: Export To PDF.

    Best regards,
    Rumen
    the Telerik team
    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 their blog feed now.
  3. gc_0620
    gc_0620 avatar
    246 posts
    Member since:
    Feb 2008

    Posted 23 Oct 2012 Link to this post

    Thanks Rumen.

    Could you please tell when exporting to RTF; not PDF, how to maintain font color/underline etc of Rad editor (i.e. Design format)?

    gc_0620
  4. Rumen
    Admin
    Rumen avatar
    14467 posts

    Posted 26 Oct 2012 Link to this post

    Hello,

    RadEditor uses two different free libraries to provide Import to RTF and Export to RTF features.

    The first one used to provide RFT to HTML importation is available in this CodeProject's article: http://www.codeproject.com/KB/recipes/RtfConverter.aspx.
    The library used for HTML to RTF exportation is available here http://www.codeproject.com/KB/HTML/XHTML2RTF.aspx.
    Both libraries are written by different developers and they are not fully compatible with each other.

    For your convenience I prepared a list of know limitations of the Import and Export features of both libraries:

    RFT to HTML (Import)

    bold
    - supported..
    italic - supported
    underline - supported
    foreground and background colors - supported
    table elements - unsupported
    images- unsupported
    indentations - unsupported
    superscript and subscript - unsupported

    HTML to RTF (export)


    bold - supported.
    italic - supported
    underline - unsupported
    foreground and background colors - unsupported
    table elements - partially supported - table borders are not exported
    images- unsupported
    indentations - supported
    font family and size - unsupported
    superscript and subscript - unsupported

    The unsupported scenarios are hard for development and require more time for implementations and testing. Our development is concentrated currently on producing valid XHTML content and the import and export problems are logged with medium priority in our ToDo list. That is why we could not provide firm estimate for when the unsupported features will be available.

    Please note that good RTF import and export tools are very expensive. If you are currently unsatisfied with the offered by RadEditor RTF functionality, you could search in Internet for another free or paid RTF to HTML importation and HTML to RTF exportation tools and you can export the content from RadEditor as shown in the following KB article: Converting RadEditor HTML to PDF format.


    All the best,
    Rumen
    the Telerik team
    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 their blog feed now.
Back to Top