Export data to PDF using RadGrid.

7 posts, 0 answers
  1. chetan
    chetan avatar
    5 posts
    Member since:
    Sep 2014

    Posted 09 Sep 2014 Link to this post

    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.

       
  2. chetan
    chetan avatar
    5 posts
    Member since:
    Sep 2014

    Posted 09 Sep 2014 Link to this post

    If Anyone knows how to handle this, please help me out. 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. chetan
    chetan avatar
    5 posts
    Member since:
    Sep 2014

    Posted 11 Sep 2014 Link to this post

    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";                        
                        }
                    }
                }
        }
        }
  5. Kostadin
    Admin
    Kostadin avatar
    1709 posts

    Posted 11 Sep 2014 Link to this post

    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.

     
  6. chetan
    chetan avatar
    5 posts
    Member since:
    Sep 2014

    Posted 12 Sep 2014 in reply to Kostadin Link to this post

    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" /> 

  7. chetan
    chetan avatar
    5 posts
    Member since:
    Sep 2014

    Posted 12 Sep 2014 Link to this post

    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";
                        }  }    }        }    }     











  8. Kostadin
    Admin
    Kostadin avatar
    1709 posts

    Posted 16 Sep 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017