Abhi Shinde
Top achievements
Rank 1
Abhi Shinde
asked on 22 Aug 2011, 03:46 PM
HI,
I want to use export data to excel of radGrid.
But My radGrid is showing only 5 columns from a DB table. I want export all columns of that table.
is that possible?
I dont want to show all the columns in radGrid.
I want to use export data to excel of radGrid.
But My radGrid is showing only 5 columns from a DB table. I want export all columns of that table.
is that possible?
I dont want to show all the columns in radGrid.
3 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Aug 2011, 06:33 PM
Hello,
Please check my below code snippet.
Let me know if any concern.
Thanks,
Jayesh Goyani
Please check my below code snippet.
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
SortExpression
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
SortExpression
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Address"
HeaderText
=
"Address"
UniqueName
=
"Address"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Email"
HeaderText
=
"Email"
UniqueName
=
"Email"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
Protected
void
RadGrid1_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName ||
e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName ||
e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName(
"Address"
).Visible =
true
;
RadGrid1.MasterTableView.Columns.FindByUniqueName(
"Email"
).Visible =
true
;
}
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0
Abhi Shinde
Top achievements
Rank 1
answered on 23 Aug 2011, 09:23 AM
hi Jayesh,
above logic is not working with GridTemplateColumn.
If
I am waiting for ur reply.
above logic is not working with GridTemplateColumn.
<
telerik:GridTemplateColumn
HeaderText
=
"Edit"
visible
=
"false"
AllowFiltering
=
"false"
UniqueName
=
"EditColumn12"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblAfter1212"
runat
=
"server"
Text='<%# Eval("_4s") %>'> </
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Gv.MasterTableView.GetColumn("EditColumn12").Visible = true;
If
visible
=
"false"
then that column will not come in excel file.I am waiting for ur reply.
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Aug 2011, 09:47 AM
Hello,
Please check below code snippet.
Let me know if any concern.
Thanks,
Jayesh Goyani
Please check below code snippet.
RadGrid1.MasterTableView.GetColumn(
"EditColumn12"
).Visible =
true
;
RadGrid1.Rebind();
Let me know if any concern.
Thanks,
Jayesh Goyani