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

Exporting Filtered Rows / DetailTables

3 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Baatezu
Top achievements
Rank 2
Baatezu asked on 03 Jul 2008, 02:34 AM
I'm having a little trouble getting only the rows I've filtered to show up when I ExportToPDF.

I have a 3 deep table. The top 2 are filterable.
I have some states, the offices qualified in those states, the people in those offices qualified in those states

When I filter only by state, it gives the desired result. When I filter by the offices, it still shows ALL the offices for that state when I export.

I'm at a loss of what to try next...
Here's my ASCX and CS (relevant code)
<telerik:RadGrid ID="grdState" runat="server" AutoGenerateColumns="False"  
    GridLines="None" ondetailtabledatabind="grdState_DetailTableDataBind"  
    onneeddatasource="grdState_NeedDataSource" AllowFilteringByColumn="True"  
    Skin="WebBlue" PageSize="5000"
    <ExportSettings FileName="StateBranchReport"  
        OpenInNewWindow="True" IgnorePaging="True"
    </ExportSettings> 
<MasterTableView datakeynames="LoanSchemaID" > 
    <DetailTables> 
        <telerik:GridTableView runat="server" Name="grdBranch" DataKeyNames="BranchID"  
            AllowFilteringByColumn="True" > 
            <DetailTables> 
                <telerik:GridTableView runat="server" Name="grdEmployees" DataKeyName="EmployeeInfo" 
                    AllowFilteringByColumn="False"
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px" /> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridTemplateColumn HeaderText="Employee Info"  
                            UniqueName="employeeinfo" DataField="EmployeeInfo"
                            <ItemTemplate> 
                                <asp:Label ID="lblEmpInfo" runat="server" Text='<%# Eval("EmployeeInfo") %>'></asp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                    </Columns> 
                </telerik:GridTableView> 
            </DetailTables> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn Visible="True"
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridTemplateColumn HeaderText="Branch" UniqueName="branch"  
                    AutoPostBackOnFilter="True" DataField="BranchName"
                    <ItemTemplate> 
                        <asp:Label ID="lblBranchName" runat="server" Text='<%# Eval("BranchName") %>'></asp:Label> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
        </telerik:GridTableView> 
    </DetailTables> 
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn visible="True"
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridTemplateColumn HeaderText="State" UniqueName="state"  
            AutoPostBackOnFilter="True" DataField="State"
            <ItemTemplate> 
                <asp:Label ID="lblState" runat="server" Text='<%# Eval("State") %>'></asp:Label> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
    </Columns> 
</MasterTableView> 
</telerik:RadGrid> 
 
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px" ClientEvents-OnRequestStart="conditionalPostback"
<asp:Button ID="cmdPDF" runat="server" onclick="cmdPDF_Click" Text="Get PDF" /> 
</telerik:RadAjaxPanel> 
 
 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"  
    EnableViewState="False"
 <script type="text/javascript">  
    function conditionalPostback(sender, args) 
    {     
     
        if(args.EventTarget == "<%= cmdPDF.UniqueID %>") 
        { 
            args.EnableAjax = false
        } 
    } 
     
</script> 
</telerik:RadScriptBlock> 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="grdCompanyTypes"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="grdCompanyTypes" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
 
        protected void grdState_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            DataSet ds = new DataSet(); 
            ds = Funcs.Create_DataSet("SELECT LoanSchemaID, State FROM gsc_aplus_LoanSchema WHERE Deleted = 0"); 
            grdState.DataSource = ds; 
        } 
        protected void grdState_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) 
        { 
            switch (e.DetailTableView.Name) 
            { 
                case "grdBranch"
                    string LoanSchemaID = e.DetailTableView.ParentItem.GetDataKeyValue("LoanSchemaID").ToString(); 
                    string SQL = "SELECT DISTINCT BO.BranchID, BO.BranchName from gsc_aplus_branchoffices as BO" 
                                + " INNER JOIN gsc_aplus_employees as E on BO.BranchID = E.BranchOfficeID" 
                                + " INNER JOIN gsc_aplus_statesauthorizedin AS SAI ON SAI.EmployeeID = E.EmployeeID" 
                                + " WHERE BO.Deleted = 0" 
                                + " AND E.Deleted = 0" 
                                + " AND E.Position < 100" 
                                + " AND SAI.LoanSchemaID = " + LoanSchemaID 
                                + " ORDER BY BranchName"
                    e.DetailTableView.DataSource = Funcs.Create_DataSet(SQL); 
                    break
                case "grdEmployees"
                    string LoanSchemaID2 = e.DetailTableView.ParentItem.OwnerTableView.ParentItem.GetDataKeyValue("LoanSchemaID").ToString(); 
                    string BranchID = e.DetailTableView.ParentItem.GetDataKeyValue("BranchID").ToString(); 
                    string SQL2 = "SELECT Convert(varchar, E.EmployeeID) + ' - ' + E.FirstName + ' ' + E.LastName AS EmployeeInfo FROM GSC_aplus_employees as E " 
                                + " INNER JOIN gsc_aplus_statesauthorizedin AS SAI ON SAI.EmployeeID = E.EmployeeID" 
                                + " WHERE E.Deleted = 0" 
                                + " AND E.Position < 100" 
                                + " AND E.BranchOfficeID = " + BranchID 
                                + " AND SAI.LoanSchemaID = " + LoanSchemaID2 
                                + " ORDER BY E.LastName"
                    e.DetailTableView.DataSource = Funcs.Create_DataSet(SQL2); 
                    break
            } 
        } 
        protected void cmdPDF_Click(object sender, EventArgs e) 
        { 
            grdState.MasterTableView.HierarchyDefaultExpanded = true
            foreach (GridTableView gtv in grdState.MasterTableView.DetailTables) 
            { 
                gtv.HierarchyDefaultExpanded = true
            } 
            grdState.MasterTableView.ExportToPdf();        
        } 

I've tried setting the line
gtv.HierarchyDefaultExpanded = true;
to false (gtv.HierarchyDefaultExpanded = false; ). I've tried alternating with IgnorePaging between true and false. When IgnorePaging is false it, essentially, displays exactly what the screen is showing. If I filter items out and expand them, then it prints what I want, but it doesn't expand the tables automatically, even when I have the DefaultExpand set to true.

I've no idea what to try, I haven't noticed any examples/sample code that demonstrate exporting multi-tier grids.

Any advice on what to try?

3 Answers, 1 is accepted

Sort by
0
Mishel
Top achievements
Rank 1
answered on 07 Jul 2008, 08:27 AM
Hi,

You should rebind the Grid in order to "gtv.HierarchyDefaultExpanded = true" has any effect. Try Rebind() and check if this will be properly applied.
0
Baatezu
Top achievements
Rank 2
answered on 07 Jul 2008, 09:15 AM
Thx for the advice, but...
I tried adding a rebind in, but it didn't seem to have any effect. My code is a little different, now, than what is posted below, but I did revert and it still didn't have any effect.

I may not have added it in the correct place, but I put it above and below the
gtv.HierarchyDefaultExpanded = true;
so it should have done something...?
0
Maria Ilieva
Telerik team
answered on 07 Jul 2008, 02:17 PM
Hi Baatezu,

Please refer to the following forum post, which discusses similar matter. Review the provided sample project, which presents exporting of filtered data and verify if it could help in your application.

Sincerely yours,
Maria Ilieva
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Baatezu
Top achievements
Rank 2
Answers by
Mishel
Top achievements
Rank 1
Baatezu
Top achievements
Rank 2
Maria Ilieva
Telerik team
Share this question
or