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

Summary Row

13 Answers 907 Views
GridView
This is a migrated thread and some comments may be shown as answers.
VLADISLAV
Top achievements
Rank 1
VLADISLAV asked on 24 Dec 2015, 10:46 AM
Im adding SummaryRows to my grid. This Rows shows as summary of whole grid and also summaries of childrows in grouped data. How can i disable summary rows for childrows.So i will see only totals for whole grid.

                GridViewSummaryItem item1 = new GridViewSummaryItem("SDSR", "{0:#0,##0.00}", GridAggregateFunction.Sum);
                GridViewSummaryItem item2 = new GridViewSummaryItem("SNDSR", "{0:#0,##0.00}", GridAggregateFunction.Sum);
                GridViewSummaryItem item4 = new GridViewSummaryItem("pl_rub", "{0:#0,##0.00}", GridAggregateFunction.Sum);
                GridViewSummaryItem item5 = new GridViewSummaryItem("pl_agent", "{0:#0,##0.00}", GridAggregateFunction.Sum);
               

                GridViewSummaryItem item11 = new GridViewSummaryItem("SDSR", "{0:N2}", GridAggregateFunction.Sum);
                GridViewSummaryItem item21 = new GridViewSummaryItem("SNDSR", "{0:N2}", GridAggregateFunction.Sum);
                GridViewSummaryItem item41 = new GridViewSummaryItem("pl_rub", "{0:N2}", GridAggregateFunction.Sum);
                GridViewSummaryItem item51 = new GridViewSummaryItem("pl_agent", "{0:N2}", GridAggregateFunction.Sum);
                
           
                GridViewSummaryRowItem row = new GridViewSummaryRowItem(new GridViewSummaryItem[] { item1, item2, item4, item5, item6 });
                this.radGridView7.SummaryRowsTop.Add(row);
                this.radGridView7.SummaryRowsBottom.Add(row);

               

                this.radGridView7.MasterTemplate.ShowTotals = true;//--------


           
                ///////////
                this.radGridView7.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Top;
                this.radGridView7.MasterView.SummaryRows[1].PinPosition = PinnedRowPosition.Bottom;
                
                GridViewSummaryRowItem summaryRowItem1 = new GridViewSummaryRowItem();
                summaryRowItem1.Add(item11);
                summaryRowItem1.Add(item21);
                summaryRowItem1.Add(item41);
                summaryRowItem1.Add(item51);

                radGridView7.MasterTemplate.SummaryRowGroupHeaders.Add(summaryRowItem1); 

13 Answers, 1 is accepted

Sort by
0
VLADISLAV
Top achievements
Rank 1
answered on 24 Dec 2015, 10:47 AM
forgot to remove item6 from GridViewSummaryRowItem row = new GridViewSummaryRowItem(new GridViewSummaryItem[] { item1, item2, item4, item5, item6 });
for this example ...
0
Dimitar
Telerik team
answered on 24 Dec 2015, 02:02 PM
Hi Vladislav,

Thank you for writing.

In order to hide the summary rows inside the groups you can use the ViewRowFormatting event:
private void RadGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
{
    if (e.RowElement.RowInfo is GridViewSummaryRowInfo && e.RowElement.RowInfo.Group != null)
    {
        e.RowElement.RowInfo.Height = 1;
    }
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
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
VLADISLAV
Top achievements
Rank 1
answered on 25 Dec 2015, 05:17 AM
Ehm let me explain the problem. Im using Spreadexport feature and getting xlsx file like pic. gr01. 
Now i need the way to fastern data export if there are too many rows in grid. To do that i thought the only data i need is group headers with appropriate sums in their columns cells .So im just hide childrows and use DoNotExport feature for hidden rows.

foreach (GridViewRowInfo row in this.radGridView7.Rows)
                    {
                        bool isVisible = false;
                        foreach (GridViewRowInfo childRow in radGridView7.ChildRows)
                        {
                            if (row == childRow)
                            {
                                isVisible = false;
                            }
                        }

                        row.IsVisible = isVisible;
                    }

And now i got pic. gr02.So i need to disable summaryrow with blue font(Group SummaryRow) but retain summaryRow with red font(SummaryRow for whole grid).
0
Stefan
Telerik team
answered on 25 Dec 2015, 08:07 AM
Hello Vladislav,

Before getting to your question, I wanted to mention that we already provide some means for faster export, one is if you do not export the grid's visual styles for the cells and the other one is to use our async exporting, which again does not export visual settings, and also, as it runs asynchronously, it does not block your application.

As to the question at hand, here is one approach you can use to hide the data rows in the groups:
private void radButton1_Click(object sender, EventArgs e)
{
    foreach (GridViewRowInfo row in radGridView1.ChildRows)
    {
        if (row is GridViewGroupRowInfo)
        {
            HideDataRowsRecursively(row.ChildRows);
        }
    }
}
 
void HideDataRowsRecursively(GridViewChildRowCollection childRows)
{
    foreach (GridViewRowInfo row in childRows)
    {
        if (row is GridViewDataRowInfo)
        {
            row.IsVisible = false;
        }
 
        if (row is GridViewGroupRowInfo)
        {
            HideDataRowsRecursively(row.ChildRows);
        }
    }
}

I hope that you find this information useful.

Regards,
Stefan
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
VLADISLAV
Top achievements
Rank 1
answered on 25 Dec 2015, 08:36 AM

Im still need visuals. 
And im still need a method to hide SummaryRows for groups, cause i can hide rows even with this part
       foreach (GridViewRowInfo row in this.radGridView7.Rows)
                    {                                        
                        row.IsVisible = false;
                    }

But after export, as u can see at the pic.gr02 there are still SummaryRows from childrows( blue font) .And i thought there is a method to hide them before export starts.

0
Stefan
Telerik team
answered on 25 Dec 2015, 08:42 AM
You can use the method I provided in the button click handler to hide the data rows in the groups. Then you can export the data with the SpreadExport. Prior running the exporter, make sure to set the HiddenRowOption of the exporter to DoNotExport. This way the exporter will not export such rows.

After the export passes, you can make your rows visible again.

Regards,
Stefan
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
VLADISLAV
Top achievements
Rank 1
answered on 25 Dec 2015, 08:54 AM
But summary rows from this childrows  still exported 
0
VLADISLAV
Top achievements
Rank 1
answered on 25 Dec 2015, 08:56 AM
Rows are hided, But summary rows still there...
0
Accepted
Stefan
Telerik team
answered on 25 Dec 2015, 09:58 AM
I thought that this was the purpose - to keep the summary rows and hide just the data rows. Anyway, here is how to hide the summary rows as well:
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.MasterTemplate.ExpandAllGroups();
 
    foreach (GridViewRowInfo row in radGridView1.ChildRows)
    {
        if (row is GridViewGroupRowInfo)
        {
            HideDataRowsRecursively((GridViewGroupRowInfo)row);
        }
    }
}
 
void HideDataRowsRecursively(GridViewGroupRowInfo groupRow)
{
    foreach (GridViewSummaryRowInfo summaryRow in groupRow.TopSummaryRows)
    {
        summaryRow.IsVisible = false;
    }
 
    foreach (GridViewSummaryRowInfo summaryRow in groupRow.BottomSummaryRows)
    {
        summaryRow.IsVisible = false;
    }
 
    foreach (GridViewRowInfo row in groupRow.ChildRows)
    {
        if (row is GridViewDataRowInfo)
        {
            row.IsVisible = false;
        }
 
        if (row is GridViewGroupRowInfo)
        {
            HideDataRowsRecursively((GridViewGroupRowInfo)row);
        }
    }
}

Let me know how this works for you.

Regards,
Stefan
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
VLADISLAV
Top achievements
Rank 1
answered on 25 Dec 2015, 11:32 AM
Thanks. Thats just what i need.
0
Arun
Top achievements
Rank 2
Iron
answered on 02 Aug 2019, 01:20 PM
If TypeOf e.RowElement.RowInfo Is GridViewSummaryRowInfo AndAlso e.RowElement.RowInfo.Group IsNot Nothing Then
              e.RowElement.RowInfo.IsVisible = False
End If
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Aug 2019, 01:16 PM
Hello, Arun, 

Could you please specify what is purpose of posting this code in the previous reply. Are you experiencing any undesired behavior? Do you need any assistance with achieving a certain requirement?

I am looking forward to your reply.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Arun
Top achievements
Rank 2
Iron
answered on 06 Aug 2019, 01:40 PM

Hi, 

I was also having the same requirement to hide the summary rows of child rows. I have followed the solution recommended by Mr. Dimitar (Admin) and found a thin line visible in the summary of child rows. Then, I tried "e.RowElement.RowInfo.IsVisible = False" it worked. So I thought it may be helpful for others too. 

Regards

Tags
GridView
Asked by
VLADISLAV
Top achievements
Rank 1
Answers by
VLADISLAV
Top achievements
Rank 1
Dimitar
Telerik team
Stefan
Telerik team
Arun
Top achievements
Rank 2
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or