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

RadGrid PDF Export

3 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kannan
Top achievements
Rank 1
Kannan asked on 23 Feb 2011, 10:24 AM

Hi,

I am exporting RadGrid Data to PDF. In that I required to insert lines horizontally and vertically. And have to make some text bold etc.

I Need help on this issues.

Can you please give me some samples?

Thanks & Regards
Kannan

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Feb 2011, 11:08 AM
Hello Kannan,

I have found the following forum discussed similar scenario
RadGrid ExporttoPDF formatting problem

Hope it helps.

Thanks,
Shinu.
0
Kannan
Top achievements
Rank 1
answered on 23 Feb 2011, 11:17 AM
Hi Shinu,

No that links doesn't help me.

I want to insert lines only for some particular rows not all the rows. And in a column some data should be bold and aligned right/left not the whole column.

So please help me in this regards

Kannan.S
0
Daniel
Telerik team
answered on 28 Feb 2011, 10:40 PM
Hello Kannan,

Below you can find a self-contained code that demonstrates how to implement the desired functionality:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" OnNeedDataSource="RadGrid1_NeedDataSource"
    OnItemCommand="RadGrid1_ItemCommand" OnItemCreated="RadGrid1_ItemCreated">
    <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" />
    <MasterTableView CommandItemDisplay="Top">
        <CommandItemSettings ShowExportToPdfButton="true" />
    </MasterTableView>
</telerik:RadGrid>

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("Col1");
    table.Columns.Add("Col2");
 
    for (int i = 0; i < 10; i++)
        table.Rows.Add(i, i);
 
    RadGrid1.DataSource = table;
}
 
bool isExport = false;
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if( e.Item is GridDataItem && isExport)
    {
        GridDataItem item = e.Item as GridDataItem;
 
        if (e.Item.ItemIndex % 2 == 0)
        {
            item["Col1"].Style.Add("border", "solid 1pt #ccc");
            item["Col2"].Style.Add("border", "solid 1pt #bba3ca");
        }
        else
        {
            item["Col1"].Style.Add("font-weight", "bolder");
            item["Col2"].Style.Add("font-size", "7pt");
        }
    }
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName.Contains("Export"))
        isExport = true;
}

Regards,
Daniel
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Kannan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kannan
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or