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

exporttoexcel does not include template columns

3 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kod
Top achievements
Rank 1
Kod asked on 27 Oct 2017, 09:04 AM

Hello,

I am trying to implement Export To Excel functionality. The issue is it does not include template columns in exported file. I am sharing my markup and code here:

protected void imgBtn_EXP_Requests_Click(object sender, EventArgs e)
       {
           RadGrid.MasterTableView.ExportToExcel();
       }
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid" AllowSorting="True" EnableViewState="true" PageSize="35" AllowPaging="True" AllowCustomPaging="false"
                AllowAutomaticUpdates="True" AllowAutomaticInserts="True" runat="server" AutoGenerateColumns="false" GridLines="None" AllowFilteringByColumn="true"
                GroupingSettings-CaseSensitive="false" ExportSettings-FileName="Dashboard" ExportSettings-ExportOnlyData="true" ExportSettings-OpenInNewWindow="true"
                ExportSettings-IgnorePaging="true" OnItemCommand="RadGrid_ItemCommand" OnItemDataBound="RadGrid_ItemDataBound">               
                <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
                <ClientSettings>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" FrozenColumnsCount="2" />
                </ClientSettings>
                <MasterTableView Width="100%" CommandItemDisplay="Top" EnableViewState="true" TableLayout="Fixed"
                    DataKeyNames="Id" AutoGenerateColumns="false" InsertItemPageIndexAction="ShowItemOnCurrentPage" >
                    <CommandItemSettings ShowAddNewRecordButton="false" />
                    <CommandItemSettings ShowRefreshButton="false" />                   
                    <Columns>
                        <telerik:GridBoundColumn DataField="Id" UniqueName="Id" HeaderText="Id"
                            AllowSorting="false" ItemStyle-Wrap="false" HeaderStyle-Wrap="false" AllowFiltering="false">
                        </telerik:GridBoundColumn>                                            
                        <telerik:GridTemplateColumn HeaderText="Request Id" ShowFilterIcon="false" UniqueName="RequestId">
                            <ItemTemplate>                               
                                <asp:LinkButton ID="lnkbtnRequestId" CausesValidation="false" runat="server" Text='<%#Eval("RequestId") %>'></asp:LinkButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Record (Title)" ShowFilterIcon="false" UniqueName="Title">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkbtnTitle" CausesValidation="false" runat="server" Text='<%#Eval("Title") %>'></asp:LinkButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>                                                
                    </Columns>
                </MasterTableView>               
            </telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Kod
Top achievements
Rank 1
answered on 27 Oct 2017, 09:06 AM
I have already tried adding DataField to template column. No luck. 
0
Kod
Top achievements
Rank 1
answered on 27 Oct 2017, 09:07 AM
I have already tried adding DataField to the template column. No luck.
0
Kod
Top achievements
Rank 1
answered on 31 Oct 2017, 03:11 PM

Here is the solution.

https://vishnukj.wordpress.com/2014/10/30/fix-for-exporting-values-in-template-columns-to-excel-for-telerik-radgrid/

Tags
Grid
Asked by
Kod
Top achievements
Rank 1
Answers by
Kod
Top achievements
Rank 1
Share this question
or