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

[Solved] How To Export the LinkColumn And no Links in the Excel?

4 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
xiaolin
Top achievements
Rank 1
xiaolin asked on 15 Sep 2009, 05:57 AM
In the Grid,My first column is linkcolumn,if I use " rgClassTreat.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML" will no screen,but no use also have links when I export to excel, I want to the only data, How to di it ?thinks

below My Code:
<
Columns>

                        <telerik:GridButtonColumn CommandName="ReadColumn" UniqueName="CHECK_JOB_ID" DataTextField="CHECK_JOB_ID" ButtonType="LinkButton" HeaderText="ID" SortExpression = "CHECK_JOB_ID"></telerik:GridButtonColumn>

                        <telerik:GridBoundColumn DataField="CUSTOMS_CODE" HeaderText="CODE" SortExpression="CUSTOMS_CODE" UniqueName="CUSTOMS_CODE" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="INPUT_DATE" DataFormatString="{0:d}" HeaderText="DATE" SortExpression="INPUT_DATE" UniqueName="INPUT_DATE" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"> </telerik:GridBoundColumn>

                          <telerik:GridButtonColumn UniqueName="Edit" CommandName="EditColumn" Text="edit" ButtonType="LinkButton" HeaderText=" edit "></telerik:GridButtonColumn>

                        <telerik:GridButtonColumn ConfirmText="Are You Sure?"  ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="Delete" HeaderText="delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">

                            <ItemStyle HorizontalAlign="Center" />

                        </telerik:GridButtonColumn>

                    </Columns> 

aspx.cs:

protected void rgClassTreat_ItemCommand(object source, GridCommandEventArgs e)

    {       

        CheckClassTreatController controller = new CheckClassTreatController();

        CheckClassTreatInfo info = new CheckClassTreatInfo() ;

        if (e.CommandName == "EditColumn")

        {

            GridEditableItem item = (GridEditableItem)e.Item;

            string documentID = item.GetDataKeyValue("DOCUMENT_ID").ToString();

            info = controller.GetCheckClassTreatByDocumentID(documentID);

            string url = "window.showModalDialog('CheckClassTreatInput.aspx?DocumentID=" + documentID + "&TreatClass=" + info.TreatClass + "', 'new', 'status:no;dialogWidth:800px;dialogHeight:600px;resizable:no');window.location.reload();";

            pnlInput.ResponseScripts.Add(url);

        }

        else if (e.CommandName == "ReadColumn")

        {

            GridEditableItem item = (GridEditableItem)e.Item;

            string documentID = item.GetDataKeyValue("DOCUMENT_ID").ToString();

            info = controller.GetCheckClassTreatByDocumentID(documentID);

            string url = "window.showModalDialog('CheckClassTreatInput.aspx?DocumentID=" + documentID + "&TreatClass=" + info.TreatClass + "&ReadOnly=" + "', 'new', 'status:no;dialogWidth:800px;dialogHeight:600px;resizable:no');";

            pnlInput.ResponseScripts.Add(url);

        }

}

 

protected void btnToExcel_Click(object sender, EventArgs e)

    {

        rgClassTreat.ExportSettings.ExportOnlyData = true;

        rgClassTreat.ExportSettings.IgnorePaging = true;

        rgClassTreat.ExportSettings.OpenInNewWindow = true;

        rgClassTreat.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;

        rgClassTreat.MasterTableView.ExportToExcel();

    }

 

 

 

 

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Sep 2009, 06:41 AM
Hi,

Here is a help article which explains how to export GridButtonColumndata to excel. Go through the section entitled: 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data' in the following document.
0
xiaolin
Top achievements
Rank 1
answered on 15 Sep 2009, 07:45 AM
sorry, It doesn't work. This is my code:
<telerik:GridButtonColumn CommandName="ReadColumn" UniqueName="CHECK_JOB_ID" DataTextField="CHECK_JOB_ID" ButtonType="LinkButton" HeaderText="ID" SortExpression = "CHECK_JOB_ID"></telerik:GridButtonColumn>
cs:
rgClassTreat.MasterTableView.Columns.FindByUniqueName( "CountryData").Visible = true;
rgClassTreat.ExportSettings.ExportOnlyData = true;

rgClassTreat.ExportSettings.IgnorePaging = true;

rgClassTreat.ExportSettings.OpenInNewWindow = true;

rgClassTreat.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;

rgClassTreat.MasterTableView.ExportToExcel();


But it doesn't work.Thank you all the same.



0
Shinu
Top achievements
Rank 2
answered on 15 Sep 2009, 08:21 AM
Hi,

Did you try adding an extra bound column which is initially hidden in the aspx declaration?

Shinu
0
xiaolin
Top achievements
Rank 1
answered on 16 Sep 2009, 01:32 AM
Yes, you are right, I had been done yesterday.But I think if I have a lot of linkcolumns That's a trouble problem.Do you have a better idea?

Thank you,Thank you very much.
Tags
Grid
Asked by
xiaolin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
xiaolin
Top achievements
Rank 1
Share this question
or