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

Export data to PDF using RadGrid.

6 Answers 122 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
chetan
Top achievements
Rank 1
chetan asked on 09 Sep 2014, 05:38 AM
Hi,

I am using the radgrid control, and using an image button to export all data to PDF file displayed in the grid, and one of the columns in the grid contains hyperlinks, though that column is not a hyperlink column, the issue i am facing is while exporting the data, i need all the hyperlinks displayed as a common text like "Download" but in addition this text should be a clickable link when seen in the pdf document.

Any kind of help will be appreciated.

Thanks.

   

6 Answers, 1 is accepted

Sort by
0
chetan
Top achievements
Rank 1
answered on 09 Sep 2014, 12:53 PM
If Anyone knows how to handle this, please help me out. 
0
chetan
Top achievements
Rank 1
answered on 11 Sep 2014, 06:32 AM
This is what i am trying to do, all the cells of a column which have hyperlinks are changed to text, but what i need is that text should be clickable hyperlink. If anyone knows the solution to this please help. 

protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
         if (isPdfExport)
        {
            GridColumn column = grdExportData.MasterTableView.GetColumn("DisclosureFileLink");
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                int columnCount = ((DataRowView)dataItem.DataItem).Row.Table.Columns.Count;
                string cellValue = string.Empty;
                string uniqueColumn = string.Empty;

                for (int x = 0; x < columnCount; x++)
                {
                    uniqueColumn = ((DataRowView)dataItem.DataItem).Row.Table.Columns["DisclosureFileLink"].ToString();
                    cellValue = ((DataRowView)dataItem.DataItem)[uniqueColumn].ToString();

                    if (!string.IsNullOrEmpty(cellValue.ToString()))
                    {
                        TableCell cell = dataItem[uniqueColumn];
                        cell.Text = "Disclosure Document";                        
                    }
                }
            }
    }
    }
0
Kostadin
Telerik team
answered on 11 Sep 2014, 01:17 PM
Hi Chetan,

A possible solution is to remove the underline of the text and change its color. More information about applying a styles could be found at the following help article. Additionally I prepared a small sample and attached it to this thread.

I hope this helps.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
chetan
Top achievements
Rank 1
answered on 12 Sep 2014, 06:11 AM
Hi Kostadin,

Thanks for your reply, the links in that particular column are appearing as links, but the text property is not working, as i want all the links in each and every cell of that column to be masked by a text , let us say "Disclosure Document", so when i try to change the text it shows no effect.
I will post my aspx , please help me out with this.
Aspx page:

  <telctrl:GridTemplateColumn HeaderText="Docs" Visible="true" HeaderStyle-Width="35px" UniqueName="TemplateColumn" >
                        <ItemTemplate>
                            <asp:Literal runat="server" Text="N/A" Visible='<%#DataBinder.Eval(Container, "DataItem.DisclosureFileLink") == null || DataBinder.Eval(Container, "DataItem.DisclosureFileLink").ToString().Length == 0%>'></asp:Literal>
                            <asp:HyperLink ID="hyprlnk" runat="server" ImageUrl="~/img/FileTypes/pdf.png" NavigateUrl='<%#DataBinder.Eval(Container, "DataItem.DisclosureFileLink")%>'
                                Visible='<%#DataBinder.Eval(Container, "DataItem.DisclosureFileLink") != null && DataBinder.Eval(Container, "DataItem.DisclosureFileLink").ToString().Length > 0%>'></asp:HyperLink>
                        </ItemTemplate>
                    </telctrl:GridTemplateColumn>

                    <telctrl:GridBoundColumn Visible="true" HeaderText="Docs" DataField="DisclosureFileLink"
                        ItemStyle-ForeColor="Blue" UniqueName="DisclosureFileLink" /> 

0
chetan
Top achievements
Rank 1
answered on 12 Sep 2014, 06:14 AM
This is how i was trying earlier.... 
bool isPdfExport = false;
    protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (isPdfExport)
        {
            GridColumn column = grdExportData.MasterTableView.GetColumn("DisclosureFileLink");
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                int columnCount = ((DataRowView)dataItem.DataItem).Row.Table.Columns.Count;
                string cellValue = string.Empty;
                string uniqueColumn = string.Empty;
                for (int x = 0; x < columnCount; x++)
                {
                    uniqueColumn = ((DataRowView)dataItem.DataItem).Row.Table.Columns["DisclosureFileLink"].ToString();
                    cellValue = ((DataRowView)dataItem.DataItem)[uniqueColumn].ToString();
                    if (!string.IsNullOrEmpty(cellValue.ToString()))
                    {
                        TableCell cell = dataItem[uniqueColumn];
                        cell.Text = "Disclosure Document";
                    }  }    }        }    }     











0
Kostadin
Telerik team
answered on 16 Sep 2014, 08:37 AM
Hello Chetan,

As far as I can see you are trying to hide the HyperLink control and display the Label. In this case you could simply find both control and switch the their Visiblity. Also I notice that you changing the cell Text property. Note that in this case the text will be display in the exported document and the controls will be cleared. Nevertheless in both cases you will not be able to redirect by using the links.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
chetan
Top achievements
Rank 1
Answers by
chetan
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or