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

Exporting with styling

3 Answers 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 20 Apr 2012, 02:30 AM
Is itpossible to set row(alternating) color for exported document like we set in radgrid.I am using built in export button for exporting.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Apr 2012, 05:33 AM
Hi Tina,

Try the following code snippet to set color for alternating rows in the exported document.

C#:
protected void radgrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
    {
        GridDataItem item = e.Cell.Parent as GridDataItem;
        if (item.ItemType == GridItemType.AlternatingItem)
        {
            item.Style["background-color"] = "Red";
        }
        else
        {
            item.Style["background-color"] = "Blue";
        }
    }

Thanks,
Princy.
0
Tina
Top achievements
Rank 1
answered on 22 Apr 2012, 05:42 PM
Thanks,
It worked.One more question.I have a column which is a date field which is alignd right by default when exporteed.Is that possible to change the alignment of the column?
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2012, 05:34 AM
Hello Tina,

Try the following code to align the text when exported.
C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
 if (e.FormattedColumn.UniqueName == "UniqueName")
 {
  e.Cell.Style["text-align"] = "center";
 }
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Tina
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Tina
Top achievements
Rank 1
Share this question
or