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

Header Context Menu with nested DetailTables causes StackOverflowException

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Théophile
Top achievements
Rank 1
Théophile asked on 20 May 2016, 09:02 AM

Hello,

I recently started to work on an old ASP.Net project and one of the first action I was asked to perform was to update Telerik version (from Q3 2012 to the last one).

The migration went almost well, but I have a problem in some specific situations : on every RadGrid with nested DetailTables, enable both HeaderContextMenu and HeaderContextFilterMenu causes a stack overflow exception during page loading.

 

Here is an example :

<telerik:RadGrid ID="RGPhase" runat="server" OnNeedDataSource="RGPhase_NeedDataSource" OnDetailTableDataBind="RGPhase_DetailTableDataBind" GridLines="None" PageSize="500" AutoGenerateColumns="false" Culture="fr-FR"
                    EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="false" AllowFilteringByColumn="true" AllowAutomaticInserts="True" AllowAutomaticUpdates="False" AllowAutomaticDeletes="False"
                    AllowPaging="True" AllowSorting="True" ShowFooter="True" OnEditCommand="RGPhase_EditCommand" OnCancelCommand="RGPhase_CancelCommand" OnUpdateCommand="RGPhase_UpdateCommand" OnDeleteCommand="RGPhase_DeleteCommand">
                    <MasterTableView DataKeyNames="IdPhaseInAffaire" IsFilterItemExpanded="false" CommandItemSettings-ShowRefreshButton="false" ShowGroupFooter="true" CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="false">
                        <NoRecordsTemplate>
                            Aucune phase
                        </NoRecordsTemplate>
                        <DetailTables>
                            <telerik:GridTableView GridLines="None" PageSize="500" AutoGenerateColumns="false" EnableHeaderContextMenu="false" EnableHeaderContextFilterMenu="false"
                                AllowFilteringByColumn="true" DataKeyNames="IdPhaseInAffaire" AllowAutomaticInserts="false" AllowAutomaticUpdates="True" AllowAutomaticDeletes="false"
                                AllowPaging="True" AllowSorting="True" ShowFooter="true" CommandItemStyle-CssClass="DontShow" CommandItemSettings-ShowRefreshButton="false" IsFilterItemExpanded="false"
                                ShowGroupFooter="true" CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="false">
                                <DetailTables>
                                    <telerik:GridTableView GridLines="None" PageSize="500" AutoGenerateColumns="false" EnableHeaderContextMenu="false" EnableHeaderContextFilterMenu="false"
                                        AllowFilteringByColumn="true" DataKeyNames="IdPhaseInAffaire" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" AllowPaging="True" AllowSorting="True"
                                        ShowFooter="true" CommandItemSettings-ShowRefreshButton="false" CommandItemStyle-CssClass="DontShow" IsFilterItemExpanded="false" ShowGroupFooter="true" CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="false">

 

And the code behind associated : 

protected void RGPhase_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            DataLoadOptions dlo = new DataLoadOptions();
            dlo.LoadWith<PhaseInAffaire>(p => p.Phase);
 
            RGPhase.DataSource = BLLPhase.GetAffairePhaseOnly(MyCompleteAffaire.IdAffaire, dlo);
        }
 
protected void RGPhase_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
 
            var idPhaseInAffaire = (int)e.DetailTableView.ParentItem.GetDataKeyValue("IdPhaseInAffaire");
 
            var pia = MyCompleteAffaire.PhaseInAffaire.Where(c => c.IdParent == idPhaseInAffaire).ToList();
 
            e.DetailTableView.DataSource = pia;
 
        }

 

When I set either "EnableHeaderContextMenu" or "EnableHeaderContextFilterMenu" to false, I have no problem loading the page.

 

Apparently the server is stuck in a recursive call of this method : Telerik.Web.UI.GridHeaderContextMenu.GridContextFilterTemplate.CheckForSpecialColumns(Telerik.Web.UI.GridTableView currentTableView).

 

Any help would be appreciated,

Thanks

2 Answers, 1 is accepted

Sort by
0
Théophile
Top achievements
Rank 1
answered on 24 May 2016, 09:11 AM

I figured it out after decompiling the Telerik.Web.UI dll. There is a bug in the "GridHeaderContextMenu.GridContextFilterTemplate.CheckForSpecialColumns" method :

if (currentTableView.HasDetailTables)
{
  foreach (GridTableView currentTableView1 in this.tableView.DetailTables)
    flag |= this.CheckForSpecialColumns(currentTableView1);
}

The foreach loop should be applied to the "currentTableView.DetailTables" collection, not the "this.tableView.DetailTables" or else the recursive call always has the root tableView children as a parameter, hence the Stack Overflow Exception if there are more than one detailTables level.

0
Konstantin Dikov
Telerik team
answered on 24 May 2016, 12:00 PM
Hi,

We received another report for StackOverflowException from the CheckForSpecialColumns method and we are going to change the search to breath-first search and list, which should eliminate eliminate the chance to get stack overflow exception. 

Please excuse us for any inconvenience caused by this.


Regards,
Konstantin Dikov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Théophile
Top achievements
Rank 1
Answers by
Théophile
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or