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

Footers Not Showing as Expected

12 Answers 501 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tonya
Top achievements
Rank 1
Tonya asked on 24 Sep 2015, 03:32 AM

I have a nested grid & need to show a few footers. The child footers show correctly, but the parent footers do not. Only 1 of the 2 parent footers displays & it displays under the wrong column.

I've attached a screenshot of my grid, showing the footers. 

Here is my code

<telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="false" AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="true" AllowPaging="false" GridLines="none" ShowFooter="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" ClientSettings-Scrolling-AllowScroll="true" ClientSettings-Scrolling-UseStaticHeaders="true" OnDataBound="RadGrid1_DataBound" >
 
    <MasterTableView DataKeyNames="ProjectID" AllowMultiColumnSorting="false" HierarchyLoadMode="Conditional" Name="ParentGrid" ShowFooter="true" >
 
        <DetailTables>
            <telerik:GridTableView DataKeyNames="DataElementID" Name="DataElementID" Width="100%" >
                <%-- Child --%>
                <HeaderStyle Font-Bold="true"/>
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="deSelectColumn" HeaderStyle-Width="5%" ></telerik:GridClientSelectColumn>
                    <telerik:GridTemplateColumn UniqueName="first" HeaderText="1st" HeaderStyle-Width="5%"
                      <ItemTemplate
                          <asp:CheckBox ID="CheckBox1" runat="server" /> 
                      </ItemTemplate
                    </telerik:GridTemplateColumn
                    <telerik:GridBoundColumn DataField="DataElementID" UniqueName="DataElementID" HeaderText="Data Element ID" DataType="System.Int16" Display="false" />
                    <telerik:GridBoundColumn DataField="ProjectAreaDescription" UniqueName="ProjectAreaDescription" HeaderText="Project Area Description" DataType="System.String" HeaderStyle-Width="50%" Aggregate="Count" FooterText="Total Count: " />
                    <telerik:GridBoundColumn DataField="ProjectDataType" UniqueName="ProjectDataType" HeaderText="Project Data Type" DataType="System.String" HeaderStyle-Width="40%" Aggregate="Custom" FooterText="Total Selected: 0" />
                     
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
 
        <%-- Parent --%>
        <HeaderStyle Font-Bold="true"/>
        <Columns>
            <telerik:GridBoundColumn DataField="ProjectID" UniqueName="ProjectID" HeaderText="Project ID" DataType="System.Int16" Groupable="true" Display="false" />
            <telerik:GridBoundColumn DataField="ProjectNumber" UniqueName="ProjectNumber" HeaderText="Project Number" DataType="System.String" HeaderStyle-Width="20%" Aggregate="Count" FooterText="Total Number of Distict Projects: " />
            <telerik:GridBoundColumn DataField="ContractNumber" UniqueName="ContractNumber" HeaderText="Contract Number" DataType="System.String" HeaderStyle-Width="20%" />
            <telerik:GridBoundColumn DataField="ProjectName" UniqueName="ProjectName" HeaderText="Project Name" DataType="System.String" HeaderStyle-Width="60%" Aggregate="Custom" FooterText="Total # Selected: " />
        </Columns>
    </MasterTableView>
 
    <ClientSettings>
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
        <Resizing AllowColumnResize="false" />
        <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true" />
    </ClientSettings>
 
</telerik:RadGrid>

As shown in the attached, the footer for ProjectNumber is not displaying at all & the footer for ProjectName is showing under Contract Number (which doesn't have a footer). The ProjectName footer is a custom aggregate & is being properly set in the RadGrid1_DataBound function. So I have a grasp of how this is done, but I don't understand why one is displaying & the other is displaying in the wrong area.

Can someone please explain?

Thanks!

Tonya

 

12 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 Sep 2015, 11:03 AM
Hi Tonya,

I have tested your RadGrid settings with dummy data and everything is working correctly on my side. Can you please elaborate which version of the controls you are using, so we can test with the exact same version?

Meanwhile, can you please try to temporarily remove all custom code that you have within the OnItemDataBound event and especially the code related to the footers and see if it will make any difference. 

Looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tonya
Top achievements
Rank 1
answered on 28 Sep 2015, 08:36 PM

Hi Konstantin-

I actually added the OnItemDataBound section to see if it would force the footers to show up. Previously I didn't have it & I had the same result. So I have tried it both ways. I've tried count values, as well as custom... just to see what works & what doesn't. The screenshot I provided, shows the result of different types of aggregates, at both the parent & child levels - where the child level works as expected & the parent does not.

I'm using version 2015.2.826. However, when I look in my Telerik Control Panel, it ​​says it's 'Partially Installed'. I proceeded to do a 'Repair' on my installation, but it continues to say the same.

Tonya

0
Viktor Tachev
Telerik team
answered on 01 Oct 2015, 10:29 AM
Hi Tonya,

Would you ensure that the calculations for the custom aggregates are executed correctly in the OnCustomAggregate event. Check out the following article that elaborates in more detail on using aggregates in RadGrid.


In case the issue persists please share the code-behind for RadGrid so we can examine it.


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tonya
Top achievements
Rank 1
answered on 01 Oct 2015, 03:34 PM

Viktor-

I'm having 2 problems...

  • The first (and more important) is that the 'count' footer in the Project Number column is not displaying at all!
  • The second is that the 'custom' footer in the Project Name column is shifted one column to the left - probably because the count footer is missing.

My custom footer is behaving exactly how I want it to. In fact, I've removed it from RadGrid1_DataBound & now have it in the code where I'm programmatically selecting the rows. This is the footer code I'm using

Dim footerItem As GridFooterItem = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0)
footerItem.Item("ProjectName").Text = "Total Number Selected: " + intTotalSelected.ToString
footerItem.Item("ProjectName").HorizontalAlign = HorizontalAlign.Right
Again, this is not the issue. The issue is with the count footer not displaying!

I've even tried using a custom footer for the Project Number footer (similar to the above) & that didn't work either. So the problem is that the footer on this field wont display!

Incidentally, if I copy the footer for Project Number & place it in the Contract Number column, it displays under the Project Number column (see attached). I would use this;  however, I need everything shifted to the right because the text for the 'count' footer will need to span 2 columns & the footer for Project Name is right aligned - and if displayed correctly, would display to the far right of the grid.

So as you can see, not having the first footer displayed is the real issue here.

0
Tonya
Top achievements
Rank 1
answered on 01 Oct 2015, 08:06 PM

[quote]Tonya said:

Incidentally, if I copy the footer for Project Number & place it in the Contract Number column, it displays under the Project Number column (see attached). I would use this;  however, I need everything shifted to the right because the text for the 'count' footer will need to span 2 columns & the footer for Project Name is right aligned - and if displayed correctly, would display to the far right of the grid.[/quote]

Since I was able to display the footer for the Contract Number under the Project Number column, I was able to span ​it across 2 columns & push the Project Name footer to the correct location. So even though this isn't working as it should, I can live with this.

However, I would still like to know why the Project Number footer does not work.

0
Viktor Tachev
Telerik team
answered on 05 Oct 2015, 11:42 AM
Hi Tonya,

I have prepared a sample project where the footers are displayed as expected on my end. Would you give it a try and let me know how it works for you? I would appreciate it if you can let me know what should be changed in the sample so that the issue you are observing is replicated.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tonya
Top achievements
Rank 1
answered on 13 Oct 2015, 02:21 AM

Viktor- 

I have modified your project & was was able to replicate the issue. The problem ​was caused when I set display=false on the column 'MasterItemID'. Not sure why this affects the footer in the 'MasterItemValue' column, but it does. I tried to attach the ​modified code, but it's not allowing me to attach a zip file, so here's the code...

ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="_RadGridHierarchy-TDvH.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptmanager1" runat="server">
        </telerik:RadScriptManager>
 
        <telerik:RadAjaxPanel ID="RadAjaxPanel3" runat="server" EnableAJAX="true">
            <%-- Tonya - Modified
            <telerik:RadGrid ID="RadGrid3" runat="server" OnNeedDataSource="RadGrid3_NeedDataSource"
                AutoGenerateEditColumn="true" RetainExpandStateOnRebind="true"
                AutoGenerateColumns="false" OnDetailTableDataBind="RadGrid3_DetailTableDataBind"
                OnItemCommand="RadGrid3_ItemCommand" ShowFooter="true" AllowPaging="true" PageSize="4" OnCustomAggregate="RadGrid3_CustomAggregate"> --%>
            <telerik:RadGrid ID="RadGrid3" runat="server" OnNeedDataSource="RadGrid3_NeedDataSource"
                OnDetailTableDataBind="RadGrid3_DetailTableDataBind" OnItemCommand="RadGrid3_ItemCommand"
                OnCustomAggregate="RadGrid3_CustomAggregate"
                AllowSorting="True" AllowMultiRowSelection="true" AllowPaging="false" GridLines="none"
                ShowStatusBar="false" AutoGenerateColumns="False" ClientSettings-Scrolling-AllowScroll="true"
                ClientSettings-Scrolling-UseStaticHeaders="true" >
                <%-- Tonya - Modified
                <MasterTableView DataKeyNames="MasterItemID" HierarchyLoadMode="ServerBind"> --%>
                <MasterTableView DataKeyNames="MasterItemID" HierarchyLoadMode="ServerBind" ShowFooter="true" >
                    <Columns>
                        <%-- Tonya - Removed the aggregate --%>
                        <telerik:GridBoundColumn DataField="MasterItemID" HeaderText="MasterItemID" UniqueName="MasterItemID" Display="false" />
                        <%-- Tonya - Changed the aggregate to count --%>
                        <telerik:GridBoundColumn DataField="MasterItemValue" HeaderText="MasterItemValue" Aggregate="Count"
                            UniqueName="MasterItemValue" />
                        <%-- Tonya - Added an additional column --%>
                        <telerik:GridBoundColumn DataField="MasterItemDesc" HeaderText="MasterItemDesc" Aggregate="Custom"
                            UniqueName="MasterItemDesc" />
                    </Columns>
                    <DetailTables>
                        <telerik:GridTableView DataKeyNames="DetailItemID" Width="100%" >
                            <Columns>
                                <telerik:GridBoundColumn DataField="DetailItemID" HeaderText="DetailItemID" UniqueName="DetailItemID">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="DetailItemValue" HeaderText="DetailItemValue"
                                    UniqueName="DetailItemValue">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ParentItemID" HeaderText="ParentItemID" UniqueName="ParentItemID">
                                </telerik:GridBoundColumn>
 
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
                </MasterTableView>
 
                <%-- Tonya - Added --%>
                <ClientSettings>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                    <Resizing AllowColumnResize="false" />
                    <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true" />
                </ClientSettings>
 
            </telerik:RadGrid>
 
            <asp:Label ID="Label1"   runat="server" />
 
        </telerik:RadAjaxPanel>
    </form>
</body>
</html>
  

CS 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
 
public partial class _Default : System.Web.UI.Page
{   
 
    protected void RadGrid3_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGrid3.DataSource = this.MasterData();
    }
    protected void RadGrid3_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        GridTableView tableView = e.DetailTableView;
        GridDataItem parentItem = tableView.ParentItem;
        int masterItemID = int.Parse(parentItem.GetDataKeyValue("MasterItemID").ToString());
        tableView.DataSource = DetailsData().FindAll(d => d.ParentItemID == masterItemID).ToList();
    }
    public List<MasterItem> MasterData()
    {
        List<MasterItem> masterItems = new List<MasterItem>();
        for (int i = 0; i < 6; i++)
        {
            //Tonya - Added an additional column
            //masterItems.Add(new MasterItem(i, "Master_Value_" + i.ToString()));
            masterItems.Add(new MasterItem(i, "Master_Value_" + i.ToString(), "Master_Description_" + i.ToString()));
        }
        return masterItems;
    }
    public List<DetailItem> DetailsData()
    {
        List<DetailItem> detailItems = new List<DetailItem>();
        for (int i = 0; i < 36; i++)
        {
            detailItems.Add(new DetailItem(i, "Detail_Value_"  + (i%6).ToString() + "_" + i.ToString(), i%6));
        }
        return detailItems;
    }
 
    protected void RadGrid3_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "CustomCommand")
        {
            Label1.Text = "CustomCommand fired at " + DateTime.Now.ToString();
        }
    }
    protected void RadGrid3_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
    {
 
        //Tonya - Moved the custom footer
        //if (e.Column.UniqueName == "MasterItemValue")
        if (e.Column.UniqueName == "MasterItemDesc")
        {
            e.Result = "My custom value";
        }
    }
}
 
public class MasterItem
{
    public int MasterItemID { get; set; }
    public string MasterItemValue { get; set; }
    public string MasterItemDesc { get; set; }
    //Tonya - Added an additional column
    //public MasterItem(int masterItemID, string masterItemValue)
    public MasterItem(int masterItemID, string masterItemValue, string masterItemDesc)
    {
        MasterItemID = masterItemID;
        MasterItemValue = masterItemValue;
 
        //Tonya - Added an additional column
        MasterItemDesc = masterItemDesc;
    }
}
public class DetailItem
{
    public int DetailItemID { get; set; }
    public string DetailItemValue { get; set; }
    public int ParentItemID { get; set; }
    public DetailItem(int detailItemID, string detailItemValue, int parentItemID)
    {
        DetailItemID = detailItemID;
        DetailItemValue = detailItemValue;
        ParentItemID = parentItemID;
    }
}
 

On a different note... after I modified things to not show paging there are only 6 rows yet the grid has a default size of about 10. Anyway to change that? It's not a big deal, I'm just curious.

Tonya

0
Viktor Tachev
Telerik team
answered on 15 Oct 2015, 01:19 PM
Hello Tonya,

I tested the behavior with the code you have provided and it works as expected on my end. Check out the following video as reference. Am I missing something?

Regarding your other query. There are only six items as that are all the items in the MasterData date source. When you expand the items a scrollbar is displayed.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tonya
Top achievements
Rank 1
answered on 15 Oct 2015, 06:07 PM

Viktor-

Unfortunately, I cannot watch the video, as my company is blocking it due to its Websense category.

I've attached screenshots of the results I see from your version of the grid & mine.

As you will see... with your version, I see the Count & the Custom footers. In the version where I have not yet set display = false on the ID column, I see the Count & Custom footers. However, when I set display = true on the ID column, I only see the Custom footer & it's shifted one column to the left, where the Count footer should be.

As per my other question, I was inquiring to the white space between the last row & the bottom of the grid. Since there are only 6 rows, I was wondering if this could be shrunk to fit the size of the rows displayed & then grow when expanding rows (if necessary).

Tonya

0
Viktor Tachev
Telerik team
answered on 20 Oct 2015, 08:26 AM
Hello Tonya,

I am afraid that without replicating the issue locally we can only guess what is causing the behavior.

I am sending the video of the behavior observed on my end as attachment. Please examine the sample project and try to use the same logic in your application.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tonya
Top achievements
Rank 1
answered on 21 Oct 2015, 01:23 AM

Viktor-

That is so strange that it works for you & not for me. As shown in the screenshots I previously attached, as soon as I change 'display=false' the footers are shifted to the left, yet in your video they are not. Unfortunately, I no longer have time to troubleshoot this, as I've had to turn things over to the customer for their review & testing.

As I stated on October 1, I was able to resolve the issue by putting the count footer on the Contract Number column (where a footer didn't exist) & since it was shifted to the left (the position I wanted), I just needed to use the span attribute to have it push the next footer​ over one column.

<Columns>
    <telerik:GridBoundColumn DataField="ProjectID" UniqueName="ProjectID" HeaderText="Project ID" DataType="System.Int16" Groupable="true" Display="false" />
    <telerik:GridBoundColumn DataField="ProjectNumber" UniqueName="ProjectNumber" HeaderText="Project Number" DataType="System.String" HeaderStyle-Width="20%" />
    <telerik:GridBoundColumn DataField="ContractNumber" UniqueName="ContractNumber" HeaderText="Contract Number" DataType="System.String" HeaderStyle-Width="20%" Aggregate="Count" FooterText="Total Number of Distict Projects: " />
    <telerik:GridBoundColumn DataField="ProjectName" UniqueName="ProjectName" HeaderText="Project Name" DataType="System.String" HeaderStyle-Width="60%" Aggregate="Custom" FooterText="Total Number Selected: 0" />
</Columns>

If RadGrid1.Items.Count <> 0 Then
    Dim footerItem As GridFooterItem = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0)
    'Span the Contract Number footer (which displays under the Project Number column) across 2 columns
    footerItem.Item("ContractNumber").ColumnSpan = 2
    'Set the custom footer & right align it
    footerItem.Item("ProjectName").Text = "Total Number Selected: " + RadGrid1.MasterTableView.ChildSelectedItems.Count.ToString
    footerItem.Item("ProjectName").HorizontalAlign = HorizontalAlign.Right
End If

I don't know why I have to go through all of this, but it works.

Thanks for all of your help on this. Too bad it will forever remain a mystery. :)

Tonya

0
Viktor Tachev
Telerik team
answered on 23 Oct 2015, 09:37 AM
Hi Tonya,

I am glad that you have found a solution for the issue.

In case you need further assistance please send us a runnable sample where the behavior is replicated. Thus, we will be able to examine the problem and look for its cause.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Tonya
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Tonya
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or