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

NestedViewTemplate Inner RadGrid Export Data

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mehmet
Top achievements
Rank 1
Mehmet asked on 18 Jul 2014, 12:29 AM
Hi Fellows,

Is there anyone has done exporting the inner grid data with the master/outer grid once clicking on the export button ?

Here is my aspx coding which may give you an idea :
001.<div class="wrapper" runat="server" id="pnlGeneralReport" visible="false">
002.                    <asp:ImageButton ID="DownloadCSV" ImageUrl="images/file-extension-csv-icon.png"
003.                        OnClick="DownloadCSV_Click" runat="server" CssClass="ImageButtons" />
004.                    <asp:ImageButton ID="generalReportHTML" runat="server" OnClick="generalReportHTML_Click" AlternateText="Html" ImageUrl="images/file-extension-xls-html-icon.png"
005.                        CssClass="pdfButton"></asp:ImageButton>
006.                    <asp:ImageButton ID="generalReportExcel" runat="server" OnClick="generalReportHTML_Click" AlternateText="ExcelML" ImageUrl="images/file-extension-xls-icon.png"
007.                        CssClass="pdfButton"></asp:ImageButton>
008.                    <asp:ImageButton ID="generalReportBiff" runat="server" OnClick="generalReportHTML_Click" AlternateText="Biff" ImageUrl="images/file-extension-xls-biff-icon.png"
009.                        CssClass="pdfButton"></asp:ImageButton>
010.                    <asp:ImageButton ID="DownloadPDF" runat="server" OnClick="DownloadPDF_Click" ImageUrl="images/file-extension-pdf-icon.png"
011.                        CssClass="pdfButton"></asp:ImageButton>
012.                    <br />
013.                    <telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" runat="server" OnItemCommand="RadGrid1_ItemCommand" OnItemCreated="RadGrid1_ItemCreated" EnableLinqExpressions="true" HtmlEncode="true" OnNeedDataSource="RadGrid1_NeedDataSource"
014.                        ShowGroupPanel="True" CellSpacing="-1" GridLines="Both" Skin="Office2010Silver" EnableViewState="true" Width="100%">
015.                        <PagerStyle Mode="NextPrevAndNumeric" />
016.                        <GroupingSettings CaseSensitive="false" />
017.                        <ClientSettings AllowKeyboardNavigation="true">
018.                        </ClientSettings>
019.                        <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
020.                            <Pdf PageHeight="210mm" PageWidth="297mm" DefaultFontFamily="Arial Unicode MS" PageTopMargin="45mm"
021.                                BorderStyle="Medium" BorderColor="#666666" PaperSize="A4">
022.                            </Pdf>
023.                        </ExportSettings>
024.                        <MasterTableView Width="100%" DataKeyNames="JobID" HierarchyLoadMode="ServerOnDemand">
025.                            <Columns>
026.                                <telerik:GridMaskedColumn DataField="JobID" HeaderText="JobID#"
027.                                    FilterControlWidth="50px" AutoPostBackOnFilter="false" CurrentFilterFunction="EqualTo"
028.                                    FilterDelay="2000" ShowFilterIcon="false" Mask="#####">
029.                                    <ColumnValidationSettings>
030.                                        <ModelErrorMessage Text=""></ModelErrorMessage>
031.                                    </ColumnValidationSettings>
032.                                </telerik:GridMaskedColumn>
033.                                <telerik:GridBoundColumn HeaderText="Customer Ref No" DataField="JobCustomerRefNo" UniqueName="JobCustomerRefNo"
034.                                    SortExpression="JobCustomerRefNo" HeaderStyle-Width="180px" FilterControlAltText="Filter JobCustomerRefNo column">
035.                                    <ColumnValidationSettings>
036.                                        <ModelErrorMessage Text=""></ModelErrorMessage>
037.                                    </ColumnValidationSettings>
038. 
039.                                </telerik:GridBoundColumn>
040.                                <telerik:GridBoundColumn DataField="JobTitle" FilterControlAltText="Filter JobTitle column" HeaderText="Job Title" SortExpression="JobTitle" UniqueName="JobTitle">
041.                                    <ColumnValidationSettings>
042.                                        <ModelErrorMessage Text="" />
043.                                    </ColumnValidationSettings>
044.                                </telerik:GridBoundColumn>
045.                                <telerik:GridDateTimeColumn DataField="JobBookedDate" PickerType="DatePicker" EnableTimeIndependentFiltering="true"
046.                                    DataFormatString="{0:dd/MM/yyyy HH:mm }" DataType="System.DateTime" FilterControlAltText="Filter JobBookedDate column" HeaderText="Job Booked Date" SortExpression="JobBookedDate" UniqueName="JobBookedDate">
047.                                    <ColumnValidationSettings>
048.                                        <ModelErrorMessage Text="" />
049.                                    </ColumnValidationSettings>
050.                                </telerik:GridDateTimeColumn>
051.                                <telerik:GridBoundColumn DataField="JobAddress1" FilterControlAltText="Filter JobAddress1 column" HeaderText="Address" SortExpression="JobAddress1" UniqueName="JobAddress1">
052.                                    <ColumnValidationSettings>
053.                                        <ModelErrorMessage Text="" />
054.                                    </ColumnValidationSettings>
055.                                </telerik:GridBoundColumn>
056.                                <telerik:GridBoundColumn DataField="JobSuburb" FilterControlAltText="Filter JobSuburb column" HeaderText="Suburb" SortExpression="JobSuburb" UniqueName="JobSuburb">
057.                                    <ColumnValidationSettings>
058.                                        <ModelErrorMessage Text="" />
059.                                    </ColumnValidationSettings>
060.                                </telerik:GridBoundColumn>
061.                                <telerik:GridBoundColumn DataField="JobPostCode" FilterControlAltText="Filter JobPostCode column" HeaderText="PostCode" SortExpression="JobPostCode" UniqueName="JobPostCode">
062.                                    <ColumnValidationSettings>
063.                                        <ModelErrorMessage Text="" />
064.                                    </ColumnValidationSettings>
065.                                </telerik:GridBoundColumn>
066.                                <telerik:GridBoundColumn DataField="JobState" FilterControlAltText="Filter JobState column" HeaderText="State" SortExpression="JobState" UniqueName="JobState">
067.                                    <ColumnValidationSettings>
068.                                        <ModelErrorMessage Text="" />
069.                                    </ColumnValidationSettings>
070.                                </telerik:GridBoundColumn>
071.                                <telerik:GridTemplateColumn DataField="JobStatusID" HeaderText="Status Type" UniqueName="JobStatusID"
072.                                    HeaderStyle-Width="200px" SortExpression="JobStatusID">
073.                                    <FilterTemplate>
074.                                        <telerik:RadComboBox ID="comboJobStatus" DataTextField="JobStatusName"
075.                                            DataValueField="JobStatusID" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("JobStatusID").CurrentFilterValue %>'
076.                                            runat="server" OnClientSelectedIndexChanged="JobStatusIndexChanged">
077.                                            <Items>
078.                                                <telerik:RadComboBoxItem Text="All" />
079.                                            </Items>
080.                                        </telerik:RadComboBox>
081.                                        <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
082.                                            <script type="text/javascript">
083.                                                function JobStatusIndexChanged(sender, args) {
084.                                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
085.                                                    tableView.filter("JobStatusID", args.get_item().get_value(), "EqualTo");
086.                                                }
087.                                            </script>
088.                                        </telerik:RadScriptBlock>
089.                                    </FilterTemplate>
090.                                    <ItemTemplate>
091.                                        <%# Eval("JobStatus") %>
092.                                    </ItemTemplate>
093.                                </telerik:GridTemplateColumn>
094.                                <telerik:GridTemplateColumn DataField="ClientID" HeaderText="Client" UniqueName="ClientID"
095.                                    HeaderStyle-Width="200px" SortExpression="ClientID">
096.                                    <FilterTemplate>
097.                                        <telerik:RadComboBox ID="comboClient" DataTextField="ClientName"
098.                                            DataValueField="ClientID" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ClientID").CurrentFilterValue %>'
099.                                            runat="server" OnClientSelectedIndexChanged="ClientIndexChanged">
100.                                            <Items>
101.                                                <telerik:RadComboBoxItem Text="All" />
102.                                            </Items>
103.                                        </telerik:RadComboBox>
104.                                        <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
105.                                            <script type="text/javascript">
106.                                                function ClientIndexChanged(sender, args) {
107.                                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
108.                                                    tableView.filter("ClientID", args.get_item().get_value(), "EqualTo");
109.                                                }
110.                                            </script>
111.                                        </telerik:RadScriptBlock>
112.                                    </FilterTemplate>
113.                                    <ItemTemplate>
114.                                        <%# Eval("Client") %>
115.                                    </ItemTemplate>
116.                                </telerik:GridTemplateColumn>
117.                                <telerik:GridTemplateColumn DataField="AssignedStaffID" HeaderText="Staff" UniqueName="AssignedStaffID"
118.                                    HeaderStyle-Width="200px" SortExpression="AssignedStaffID">
119.                                    <FilterTemplate>
120.                                        <telerik:RadComboBox ID="comboStaff" DataTextField="StaffName"
121.                                            DataValueField="StaffID" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("AssignedStaffID").CurrentFilterValue %>'
122.                                            runat="server" OnClientSelectedIndexChanged="StaffIndexChanged">
123.                                            <Items>
124.                                                <telerik:RadComboBoxItem Text="All" />
125.                                            </Items>
126.                                        </telerik:RadComboBox>
127.                                        <telerik:RadScriptBlock ID="RadScriptBlock10" runat="server">
128.                                            <script type="text/javascript">
129.                                                function StaffIndexChanged(sender, args) {
130.                                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
131.                                                    tableView.filter("AssignedStaffID", args.get_item().get_value(), "EqualTo");
132.                                                }
133.                                            </script>
134.                                        </telerik:RadScriptBlock>
135.                                    </FilterTemplate>
136.                                    <ItemTemplate>
137.                                        <%# Eval("AssignedStaff") %>
138.                                    </ItemTemplate>
139.                                </telerik:GridTemplateColumn>
140.                            </Columns>
141.                            <NestedViewTemplate>
142.                                <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">
143.                                    <telerik:RadGrid runat="server" ID="JobStatusGrid" OnNeedDataSource="JobStatusGrid_NeedDataSource">
144.                                        <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
145.                                            DataKeyNames="JobStatusHistoryID" PageSize="7" HierarchyLoadMode="Client">
146.                                            <Columns>
147.                                                <telerik:GridBoundColumn HeaderText="Status Type" HeaderButtonType="TextButton"
148.                                                    DataField="JobStatus" UniqueName="JobStatusID">
149.                                                </telerik:GridBoundColumn>
150.                                                <telerik:GridBoundColumn HeaderText="Created By" HeaderButtonType="TextButton"
151.                                                    DataField="CreatedBy" UniqueName="CreatedBy">
152.                                                </telerik:GridBoundColumn>
153.                                                <telerik:GridBoundColumn HeaderText="Created On" HeaderButtonType="TextButton"
154.                                                    DataField="CreatedOn" UniqueName="CreatedOn">
155.                                                </telerik:GridBoundColumn>
156.                                            </Columns>
157.                                        </MasterTableView>
158.                                    </telerik:RadGrid>
159.                                </asp:Panel>
160.                            </NestedViewTemplate>
161.                        </MasterTableView>
162.                        <ClientSettings AllowDragToGroup="true">
163.                            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
164.                        </ClientSettings>
165.                    </telerik:RadGrid>
166.                </div>

I appreciate your help.

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 22 Jul 2014, 01:46 PM
Hi Mehmet,

If you would like to create a RadGrid with hierarchical structure you could use the built-in functionality provided by the control. The Master and Detail tables for the RadGrid provide an easy way to present hierarchical data. Check out the following resources that elaborate more on the matter:

Regarding the export of RadGrid data I recommend taking a look at the following resources that illustrate how hierarchical RadGrid could be exported:

I hope this information would be helpful.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Mehmet
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or