Detail Table Not expanding

3 posts, 1 answers
  1. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 27 Sep 2012 Link to this post

    I have a screen with a radgird that has a master table and a detail table.  When I Expand a record that has no detail information the grid expands and shows No Child Record To Display, but when I click on a record that has detail information nothin happens.

    <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2007" AllowPaging="True" EnableLinqExpressions="false" AllowCustomPaging="true" AutoGenerateColumns="False" GridLines="None" AllowSorting="true" AllowFilteringByColumn="false" AlternatingItemStyle-BackColor="#eeeeee" ShowGroupPanel="False" ShowStatusBar="True" OnNeedDataSource="RadGrid1_NeedDataSource"                                  OnPreRender="RadGrid1_PreRender" OnDetailTableDataBind="HistoryDetail_NeedDataSource">
                 <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
                 <MasterTableView DataKeyNames="MarketingID"  PagerStyle-Mode="NextPrevNumericAndAdvanced" >
                        <GroupByExpressions>
                                <telerik:GridGroupByExpression>
                                       <SelectFields>
                                                <telerik:GridGroupByField FieldAlias="ClientName" HeaderText="Client" FieldName="ClientName"
                                                         HeaderValueSeparator=" : "></telerik:GridGroupByField>
                                       </SelectFields>
                          <GroupByFields>
                              <telerik:GridGroupByField FieldName="ClientName" HeaderText="Client" SortOrder="Ascending">
                              </telerik:GridGroupByField>
                          </GroupByFields>
                       </telerik:GridGroupByExpression>
                  </GroupByExpressions>
                  <RowIndicatorColumn>
                     <HeaderStyle Width="20px"></HeaderStyle>
                   </RowIndicatorColumn>
                   <ExpandCollapseColumn>
                         <HeaderStyle Width="20px"></HeaderStyle>
                   </ExpandCollapseColumn>
                        <Columns>
                               <telerik:GridBoundColumn DataField="MarketingID" HeaderText="MarketingID" SortExpression="MarketingID"  UniqueName="MarketingID" Visible="false">
                               </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ClientID" UniqueName="ClientID" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="MarketingFormattedID" HeaderText="Marketing ID"
                                           ItemStyle-Width="85" SortExpression="MarketingFormattedID" UniqueName="MarketingFormattedID"
                                            Visible="true" ItemStyle-VerticalAlign="Top">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridBoundColumn DataField="MarketingTypeName" HeaderText="Marketing Type"
                                                  ItemStyle-VerticalAlign="Top" SortExpression="" AllowSorting="false"  UniqueName="MarketingTypeName"        Visible="true">
                                 </telerik:GridBoundColumn>
                       </Columns>
                      <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
                                              
                      <DetailTables>
                           <telerik:GridTableView DataKeyNames="MarketingID"  runat="server"  >
                                 <ParentTableRelation>
                                         <telerik:GridRelationFields DetailKeyField="MarketingID" MasterKeyField="MarketingID" />
                                 </ParentTableRelation>
                                 <Columns>
                                        <telerik:GridBoundColumn HeaderText="Status"  DataField="MarketingStatusTypeName" UniqueName="MarketingStatusTypeName">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn  HeaderText="Changed By"  DataField="ChangedBy" UniqueName="ChangedBy">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Date Changed"  DataField="DateChanged" UniqueName="DateChanged">
                                        </telerik:GridBoundColumn>
                            </Columns>                                                
                  </telerik:GridTableView>
             </DetailTables>
          </MasterTableView>
         <ClientSettings AllowDragToGroup="True">
              <Selecting AllowRowSelect="True" />
         </ClientSettings>
         <FilterMenu Skin="Office2007" EnableTheming="True">
              <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
         </FilterMenu>
      </telerik:RadGrid>

    and here is the OnDetailTableDataBind Code
    protected void HistoryDetail_NeedDataSource(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
            {
      
                GridDataItem dataItem = e.DetailTableView.ParentItem;
      
                ClientDataContext db = new ClientDataContext();
                var query = from m in db.MarketingStatusChangeLogs
                            where (m.MarketingID == int.Parse(dataItem.GetDataKeyValue("MarketingID").ToString()))
                            select new
                            {
                                m.MarketingStatusType.MarketingStatusTypeName,
                                m.ChangedBy,
                                m.DateChanged
                            };
                e.DetailTableView.DataSource = query;
            }


    am I missing something?
  2. Answer
    Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 28 Sep 2012 Link to this post

    The issue is in the HistoryDetail_NeedDataSource, you need to include MarketingID in the query.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 29 Sep 2012 Link to this post

    Hello Frank,

    I have examined the provided code and I think that the problem is in the query. I received and exception in the query saying that LINQ to Entities does not recognize the parse method. Try extracting the MarketingID before the query. Here is a code snippet:
    protected void HistoryDetail_NeedDataSource(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
     
            GridDataItem dataItem = e.DetailTableView.ParentItem;
     
            ClientDataContext db = new ClientDataContext();
            int marketingID = int.Parse(dataItem.GetDataKeyValue("MarketingID").ToString());
            var query = from m in db.MarketingStatusChangeLogs
                        where (m.MarketingID == marketingID)
                        select new
                        {
                            m.MarketingStatusType.MarketingStatusTypeName,
                            m.ChangedBy,
                            m.DateChanged
                        };
            e.DetailTableView.DataSource = query;
        }

    I am also attaching a sample project which is replicating your scenario.

    Regards,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top