8 Answers, 1 is accepted
Please post or attach your code so we can examine your approach. In the meantime you can try to reproduce the problem in our online demo:
MS Excel/MS Word/CSV
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
//1. Button event to handle Word Export
void btnDownloadToWord_Click(object sender, EventArgs e)
{
Export(
"Word");
}
//2. Export Function
private void Export(string exportTo)
{
//Replace Hyperlink column with a Template Column.
for (int i = 0; i < RadGrid1.MasterTableView.Columns.Count; i++)
{
GridColumn column = RadGrid1.MasterTableView.Columns[i];
if (column is GridHyperLinkColumn)
{
string columnname = column.UniqueName;
GridTemplateColumn newcolumn = new GridTemplateColumn();
newcolumn.UniqueName = columnname +
"Link";
newcolumn.HeaderText = column.HeaderText;
RadGrid1.MasterTableView.Columns.AddAt(column.OrderIndex - 1, newcolumn);
i++;
column.Visible =
false;
}
}
RadGrid1.MasterTableView.AllowSorting =
false;
RadGrid1.MasterTableView.AllowPaging =
false;
RadGrid1.MasterTableView.AllowFilteringByColumn =
true;
RadGrid1.Rebind();
for (int i = 0; i < RadGrid1.MasterTableView.Columns.Count; i++)
{
GridColumn column = RadGrid1.MasterTableView.Columns[i];
if (column is GridHyperLinkColumn)
{
string columnname = column.UniqueName;
foreach (GridItem item in RadGrid1.MasterTableView.Items)
{
if (item is GridDataItem)
{
GridDataItem dataItem = (GridDataItem)item;
string button = "";
foreach (Control Link in dataItem[columnname].Controls)
if (Link is HyperLink)
button = ((
HyperLink)Link).Text;
Literal literal = new Literal();
literal.Text = button;
dataItem[columnname +
"Link"].Controls.Add(literal);
}
}
}
}
switch (exportTo)
{
case "Word":
RadGrid1.MasterTableView.ExportToWord();
break;
case "Excel":
RadGrid1.MasterTableView.ExportToExcel();
break;
case "CSV":
RadGrid1.MasterTableView.ExportToCSV();
break;
}
}
Please try to modify your button click event this way:
void btnDownloadToWord_Click(object sender, EventArgs e){ //Export("Word"); RadGrid1.MasterTableView.ExportToWord();}Let me know whether this helps.
Best regards,
Daniel
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
I'm afraid I ran out of ideas as to what could be wrong - this is not a common problem.
Could you please provide a runnable version of your project so I can debug it locally? You can attach it to a formal support ticket (with reference to this thread).
Best regards,
Daniel
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Thanks
Unfortunately we couldn't reproduce the problem on our end. In most of the cases we could suggest a workaround if we have a runnable project that demonstrates the problem.
I will do my best to provide a fix for this behavior if you could attach a runnable demo.
Best regards,
Daniel
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.