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

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

3 Answers 69 Views
Editor
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 18 Oct 2012, 09:43 PM

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>

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 23 Oct 2012, 11:17 AM
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.
0
gc_0620
Top achievements
Rank 1
answered on 24 Oct 2012, 12:15 AM
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
0
Rumen
Telerik team
answered on 26 Oct 2012, 01:01 PM
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.
Tags
Editor
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Rumen
Telerik team
gc_0620
Top achievements
Rank 1
Share this question
or