Multiple Detailstables at one level only showing one

4 posts, 0 answers
  1. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 22 Dec 2008 Link to this post

    Hello,

    I followed your sample code to have mutliple DetailsTables (2), but can't get the second table to show up.

    When I trace the binding event of the detailstables, both get filled with data, but only one shows up. If I change the order of the detailstables, then the other table will show with data, but again the second one in the hierachie (with index = 1) wont show.

    Any help would be appreciated. Here's my code.

    Context: Visual Studio 2008, .Net 3.5 with LinQ to SQL, Telerik Q2 2008 release.

    Using OnNeedDataSource and OnDetailTableDataBind.

    Aspx code:

    <telerik:RadGrid ID="RadGrid1" Skin="Web20" ShowStatusBar="True" AllowSorting="True"
    PageSize="1000" HorizontalAlign="Left" runat="server" AllowFilteringByColumn="True" ShowHeader="true"
    Height="100%" Width="100%" OnDetailTableDataBind="radgrid1_detailtabledatabind" OnNeedDataSource="radgrid1_needdatasource" ShowGroupPanel="True" AllowAutomaticInserts="false"
    GridLines="None" OnItemCommand="radgrid_insert" AutoGenerateColumns="False" EnableLinqExpressions="False" ShowFooter="False">
    <GroupHeaderItemStyle Height="20px" />
    <ExportSettings FileName="AthleteExport">
    <Csv ColumnDelimiter="Semicolon" />
    </ExportSettings>
    <MasterTableView TableLayout="Auto" DataKeyNames="OID, ParentOID" ClientDataKeyNames="OID, ParentOID"
    GroupLoadMode="Server">
    <ItemStyle Height="20px" />
    <AlternatingItemStyle Height="20px" />
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
    <DetailTables>
    <telerik:GridTableView CommandItemDisplay="TopAndBottom"
    InsertItemDisplay="Top" AllowAutomaticInserts="true"
    DataKeyNames="AddressOID" ClientDataKeyNames="AddressOID" Width="100%"
    AllowFilteringByColumn="False" BorderColor="#FF9933" BorderWidth="2px" GridLines="None"
    Caption="Addresses" HierarchyLoadMode="ServerOnDemand">
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="AthleteOID" MasterKeyField="ParentOID" />
    </ParentTableRelation>
    <ItemStyle Font-Italic="true" Font-Bold="False" Font-Names="Microsoft Sans Serif"
    Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" />
    <AlternatingItemStyle Font-Italic="true" />
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>

    <Columns>
    <telerik:GridBoundColumn DataField="Street" UniqueName="Street" HeaderText="Street">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="City" UniqueName="City" HeaderText="City">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="AddressOID" ReadOnly="True" UniqueName="AddressOID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="AthleteOID" ReadOnly="True" UniqueName="AthleteOID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>

    </Columns>
    <HeaderStyle BackColor="#FF9933" Font-Bold="False" Font-Italic="False" Font-Overline="False"
    Font-Strikeout="False" Font-Underline="False" Wrap="True" />
    </telerik:GridTableView>
    <telerik:GridTableView CommandItemDisplay="TopAndBottom"
    InsertItemDisplay="Top" AllowAutomaticInserts="true"
    DataKeyNames="OrderOID" ClientDataKeyNames="OrderOID" Width="100%"
    AllowFilteringByColumn="False" BorderColor="#FF9933" BorderWidth="2px" GridLines="None"
    Caption="Orders" HierarchyLoadMode="ServerOnDemand">
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="AthleteOID" MasterKeyField="OID" />
    </ParentTableRelation>
    <ItemStyle Font-Italic="true" Font-Bold="False" Font-Names="Microsoft Sans Serif"
    Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" />
    <AlternatingItemStyle Font-Italic="true" />
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>

    <Columns>
    <telerik:GridBoundColumn DataField="DateCreated" UniqueName="DateCreated" HeaderText="Created"
    DataFormatString="{0:d}">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="DateSent" UniqueName="DateSent" HeaderText="Sent"
    DataFormatString="{0:d}">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="Status" UniqueName="Status" HeaderText="Status">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="FileName" UniqueName="FileName" HeaderText="File">
    <HeaderStyle HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="RS" UniqueName="RS" HeaderText="RS">
    <HeaderStyle Width="100px" HorizontalAlign="Left" />
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="AthleteOID" ReadOnly="True" UniqueName="AthleteOID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="OrderOID" ReadOnly="True" UniqueName="OrderOID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>
    </Columns>
    <HeaderStyle BackColor="#FF9933" Font-Bold="False" Font-Italic="False" Font-Overline="False"
    Font-Strikeout="False" Font-Underline="False" Wrap="True" />
    </telerik:GridTableView>
    </DetailTables>
    <Columns>
    <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/styles/images/orders_icon.png" CommandArgument="showOrders"></telerik:GridButtonColumn>
    <telerik:GridBoundColumn DataField="OID" ReadOnly="True" UniqueName="OID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="ParentOID" ReadOnly="True" UniqueName="ParentOID" Visible="False" HeaderText="" >
    </telerik:GridBoundColumn>
    <custom:MyGridCustomFilter DataField="Prefix" UniqueName="Prefix" HeaderText="RS" HeaderStyle-Width="40px" ItemStyle-Width="40px">
    </custom:MyGridCustomFilter>
    <telerik:GridBoundColumn DataField="LastName" UniqueName="LastName" HeaderText="Lastname">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="FirstName" UniqueName="FirstName" HeaderText="FirstName">
    </telerik:GridBoundColumn>
    <custom:MyGridCustomFilter DataField="Gender" UniqueName="Gender" HeaderText="Gender">
    </custom:MyGridCustomFilter>
    <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Nat." AllowFiltering="true">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="DateOfBirth" UniqueName="DateOfBirth" HeaderText="Date Of Birth"
    DataFormatString="{0:d}">
    </telerik:GridBoundColumn>
    <custom:MyGridCustomFilter ItemStyle-Wrap="false" HeaderStyle-Width="25%" ItemStyle-Width="25%"
    DataField="AgentName" UniqueName="AgentName" HeaderText="Agent">
    <HeaderStyle Width="25%"></HeaderStyle>
    <ItemStyle Wrap="False" Width="25%"></ItemStyle>
    </custom:MyGridCustomFilter>
    <custom:MyGridCustomFilter DataField="Categorie" UniqueName="Categorie" HeaderText="Cat.">
    </custom:MyGridCustomFilter>
    </Columns>
    </MasterTableView>
    <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="true" AllowGroupExpandCollapse="true">
    <ClientEvents OnRowDblClick="RowDblClick" />
    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" />
    <Selecting AllowRowSelect="true" />
    </ClientSettings>
    <FilterMenu Skin="Web20" EnableTheming="True">
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
    </FilterMenu>
    <GroupingSettings CaseSensitive="false" />
    </telerik:RadGrid>



    OnNeedDataSource:


    protected void radgrid1_needdatasource(object source, GridNeedDataSourceEventArgs e)
    {
    DataClassesDataContext ctx = ContextManager.GetActiveContext();

    string gender = Request.QueryString["gender"];
    string cat = Request.QueryString["cat"];

    if (cat == "TF") cat = "T&F"; //todo hack!!

    string categorie = Server.UrlDecode(cat);


    var qry = Athletes.GetGridData(ctx, gender, categorie);

    var athletes =
    qry.Select(
    q =>
    new
    {
    q.AgentName,
    q.Categorie,
    q.DateOfBirth,
    q.FirstName,
    q.Gender,
    q.LastName,
    q.Name,
    q.OID,
    q.Prefix,
    ParentOID = q.OID
    });

    var list = athletes.ToList();
    RadGrid1.DataSource = list;


    //create dropdownlists for filters
    CreateColumnDropdowns();

    }

    private void CreateColumnDropdowns()
    {
    foreach (GridColumn gridColumn in RadGrid1.MasterTableView.Columns)
    {
    if (gridColumn.GetType() == typeof(MyGridCustomFilter))
    {
    MyGridCustomFilter column = gridColumn as MyGridCustomFilter;

    if (column.UniqueName == "AgentName")
    {
    column.ListDataSource = GetFilterTable(column.DataField);
    }

    else if (column.UniqueName == "Gender")
    {
    column.ListDataSource = GetFilterTable(column.DataField);
    }

    else if (column.UniqueName == "Prefix")
    {
    column.ListDataSource = GetFilterTable(column.DataField);
    }

    else if (column.UniqueName == "Categorie")
    {
    column.ListDataSource = GetFilterTable(column.DataField);
    }
    }

    }
    }




    OnDetailTableDataBind:


    protected void radgrid1_detailtabledatabind(object source, GridDetailTableDataBindEventArgs e)
    {

    if (e.DetailTableView.DetailTableIndex == 0) //addresses subtable
    {
    IQueryable<view_Address> qryAddress = EntityController<view_Address>.RetrieveAll();

    var adres =
    qryAddress.Select(
    q =>
    new
    {
    q.AthleteOID,
    q.Street,
    q.Zip,
    q.Country,
    q.City,
    q.AddressOID
    });

    var addresses = adres.ToList();

    RadGrid1.MasterTableView.DetailTables[0].DataSource = addresses;
    RadGrid1.MasterTableView.DetailTables[0].Visible = true;

    GridRelationFields relationFields = new GridRelationFields();
    RadGrid1.MasterTableView.DetailTables[0].ParentTableRelation.Add(relationFields);
    relationFields.MasterKeyField = "ParentOID";
    relationFields.DetailKeyField = "AthleteOID";
    //end addresses subtable
    }
    else if(e.DetailTableView.DetailTableIndex == 1)//orders subtable
    {
    IQueryable<Order> qry = EntityController<Order>.RetrieveAll();

    var t =
    qry.Select(
    q =>
    new
    {
    OrderOID = q.OID,
    q.Status,
    q.DateCreated,
    q.DateSent,
    q.AthleteOID,
    q.filename,
    RS = q.SystemUser.ToString()
    });

    var orders = t.ToList();
    RadGrid1.MasterTableView.DetailTables[1].DataSource = orders;
    RadGrid1.MasterTableView.DetailTables[1].Visible = true;

    GridRelationFields relationFields = new GridRelationFields();
    RadGrid1.MasterTableView.DetailTables[1].ParentTableRelation.Add(relationFields);
    relationFields.MasterKeyField = "OID";
    relationFields.DetailKeyField = "AthleteOID";

    //end orders subtable
    }


    }
  2. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 22 Dec 2008 Link to this post

    FYI. Upgraded to 2008 Q3 release, but still only the first table will show up.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 23 Dec 2008 Link to this post

    I found out the table is actually getting filled in the rendered page, but the tables are next to eachother instead of under eachother. Thats why the second table actually is on the page, but not showing up. Will get back to you when I solve the CSS issue.
  5. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 23 Dec 2008 Link to this post

    Had some floats above the grid. This was causing the problems. Here's how I solved it by adding some css to the page:

    .DetailTable_Web20

     

     

    {

        display:block !important;

     

     

        clear:both !important;

     

    }

Back to Top