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

Grid with Export

4 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avinash
Top achievements
Rank 1
Avinash asked on 25 Mar 2011, 08:42 PM
Hi,

I have a requirement like:

I have a datatable with 10 columns, out of which I am showing only 5 columns on page. Page also have export button, which is working fine and exporting only five columns with sorting & filtering.

Now due to some requirement , client is expecting to show 5 columns as is on page but while exporting, excel should contain all 10 columns.

Is it possible to full fill this requirement?

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Mar 2011, 05:43 AM
Hi Avinash,

add colunm in your code and set visible to false.
<telerik:GridBoundColumn UniqueName="Column6" DataField="YourDataField"  Visible="false">

and when you export command fire at that time you set visible=true of that extra columns.
protected void Radgrid1_ItemCommand(object source, GridCommandEventArgs e)
{
     if(e.CommandName == "ExportToExcel")
     {
             Radgrid1.MasterTableView.Columns.FindByUniqueName("Column6").Visible = true;
     }
}

let me know if any concern

Thanks,
Jayesh Goyani
0
Avinash
Top achievements
Rank 1
answered on 28 Mar 2011, 02:36 PM
Hi Jayesh,

This is not working as ItemCommand is not getting fired when I click on export button.

I think I have to check in exporting event itself.

Thank you for giving me an idea.
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 28 Mar 2011, 02:46 PM
hi Avinash,

Radgrid1.MasterTableView.Columns.FindByUniqueName("Column6").Visible = true;
Radgrid1.MasterTableView.ExportToExcel();

sorry for that i think that u want to export from inbuilt export command's button.
above code is help full to you.

Thanks,
Jayesh Goyani
0
Avinash
Top achievements
Rank 1
answered on 28 Mar 2011, 02:50 PM
Cool.

It is working. Thank you.
Tags
Grid
Asked by
Avinash
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Avinash
Top achievements
Rank 1
Share this question
or