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

exporting to excel template columns

2 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
doug
Top achievements
Rank 2
doug asked on 06 Mar 2014, 04:12 PM
I have a radgrid that has two "edit" columns for input.  when the user clicks "imageButton2" the export works fine, but the two template columns don't show up.


<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="Excel_ExcelML.png"  OnClick="ImageButton_Click" AlternateText="ExcelML" />
  
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" AutoGenerateColumns="False"   OnItemCommand="RadGrid1_ItemCommand" OnNeedDataSource="RadGrid1_NeedDataSource" GridLines="None" ShowGroupPanel="True" Skin="Metro">
            <GroupingSettings GroupItemsWrapperTableCaption="Sales Planning Model" />
            <ClientSettings AllowDragToGroup="True">
            </ClientSettings>
            <ExportSettings ExportOnlyData="true">           </ExportSettings>
            <MasterTableView AutoGenerateColumns="false"  CommandItemDisplay="Bottom" GroupsDefaultExpanded="False" ShowGroupFooter="True" >
                <Columns>
                    <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Forecast" UniqueName="TemplateColumn">
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="typedesc" FilterControlAltText="Filter typedesc column" HeaderText="typedesc" UniqueName="typedesc">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="bill_to_name" FilterControlAltText="Filter bill_to_name column" HeaderText="Bill To Name" UniqueName="bill_to_name">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="jan"  Aggregate="Sum" FilterControlAltText="Filter jan column" DataFormatString="{0:###,##0.0}" HeaderText="Jan" UniqueName="jan">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="feb" Aggregate="Sum" FilterControlAltText="Filter feb column" DataFormatString="{0:###,##0.0}" HeaderText="Feb" UniqueName="feb">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Mar"  Aggregate="Sum" FilterControlAltText="Filter Mar column" DataFormatString="{0:###,##0.0}" HeaderText="Mar" UniqueName="Mar">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="month3Avg" Aggregate="Sum" FilterControlAltText="Filter month3Avg column" DataFormatString="{0:###,##0.0}" HeaderText="3 month Avg" UniqueName="month3Avg">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Forecast (Increment)" UniqueName="colForecast">
                        <ItemTemplate>
                            <telerik:RadNumericTextBox ID="RadForecast" uniqueName="RadForecast" Width="80px" DataFormatString="{0:###,##0.0}" Value="0.0" runat="server"></telerik:RadNumericTextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                      <telerik:GridTemplateColumn HeaderText="Notes" UniqueName="colNotes">
                        <ItemTemplate>
                            <asp:TextBox ID="txtNotes" uniqueName="txtNotes" runat="server" Columns="30" MaxLength="30"></asp:TextBox>
                        </ItemTemplate>                    </telerik:GridTemplateColumn>
                </Columns>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="typeDesc" FieldName="typeDesc" FormatString="" HeaderText="By Type Description" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldAlias="typeDesc" FieldName="typeDesc" FormatString="" HeaderText="" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>            </MasterTableView>
        </telerik:RadGrid>

My code-behind

​Protected Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs)
For Each item As GridDataItem In RadGrid1.MasterTableView.Items
Dim _forecast As RadNumericTextBox = TryCast(item("colForecast").FindControl("RadForecast"), RadNumericTextBox)
item("colForecast").Text = _forecast.Text
Dim _notes As TextBox = TryCast(item("colNotes").FindControl("txtNotes"), TextBox)
item("colNotes").Text = _notes.Text

Next
RadGrid1.MasterTableView.ExportToCSV()
End Sub

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Mar 2014, 05:29 AM
Hi Doug,

Please set ExportOnlyData="false" to export the TemplateColumns.

ASPX:
<ExportSettings ExportOnlyData="false">
</ExportSettings>

Thanks,
Princy
0
doug
Top achievements
Rank 2
answered on 07 Mar 2014, 04:06 PM
thanks it worked.
Tags
Grid
Asked by
doug
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
doug
Top achievements
Rank 2
Share this question
or