Summary Row

11 posts, 1 answers
  1. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 24 Dec 2015 Link to this post

    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); 
  2. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 24 Dec 2015 in reply to VLADISLAV Link to this post

    forgot to remove item6 from GridViewSummaryRowItem row = new GridViewSummaryRowItem(new GridViewSummaryItem[] { item1, item2, item4, item5, item6 });
    for this example ...
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 24 Dec 2015 Link to this post

    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
  5. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 24 Dec 2015 Link to this post

    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).
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Dec 2015 Link to this post

    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
  7. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 25 Dec 2015 Link to this post

    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.

  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Dec 2015 Link to this post

    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
  9. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 25 Dec 2015 Link to this post

    But summary rows from this childrows  still exported 
  10. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 25 Dec 2015 Link to this post

    Rows are hided, But summary rows still there...
  11. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Dec 2015 Link to this post

    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
  12. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 25 Dec 2015 Link to this post

    Thanks. Thats just what i need.
Back to Top
UI for WinForms is Visual Studio 2017 Ready