Home › Forums › WinForms controls › Xceed Grid for WinForms › reapplying summaryrow
-
AuthorPosts
-
#14741 |
I have created a group which shows summary row in footerrows, which works fine. The problem is when i collapse the group and reapply it again I dont get the footer rows back. Can someone help me with this. Also, I have to mention I’m new to this.
Thx in advance
NickImported from legacy forums. Posted by fullstop (had 2975 views)
This should work fine. It may be due to the way you first set it up. Normally, you add a group, which creates a group template, and use this group template to add the summary row. You fill the data to the grid after that, so the template is applied.
Imported from legacy forums. Posted by André (had 221 views)
Thx for the quick reply, however this is not working. Here is my code..
GridControl1.BeginInit()
Dim myDataView As DataView = DataSet11.Tables(“customers”).DefaultView
myDataView.RowFilter = “(custid= ‘” & Trim(TextBox1.Text) & “‘) “‘)”
Me.GridControl1.DataSource = myDataViewMe.GridControl1.Columns(“custQTY”).VisibleIndex = 1
Dim sRow As New SummaryRow
Dim group As Group = New Group
group.GroupBy = “custQTY”Me.GridControl1.GroupTemplates.Add(group)
CType(srow.Cells(“custQTY”), SummaryCell).StatFunction = Xceed.Grid.StatFunction.Sum
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
gridcontrol1.endinit()
ValidateGridControl()so when i run the form, i get the group and it’s sums in the footer row, but when i drop it down to the table and reapply it back footer rows of the group are not there.
dont know what im doing wrong …Ive tried to add an eventhandler which i found on the forum, and i managed to get a footer row each time the group is applied however row doesnt display sums…this is what i add as eventhandlerPrivate Sub grid_GroupingUpdated(ByVal sender As Object, ByVal e As EventArgs)
For Each grp As Group In GridControl1.Groups
Dim sumRow As Xceed.Grid.ValueRow = New Xceed.Grid.ValueRow
grp.FooterRows.Add(sumRow)
Dim sum As Double
For Each row As DataRow In grp.GridControl.DataRows
sum += CType(row.Cells(“custQTY”).Value, Double)Next
‘sum = sumRow.Cells(“custQTY”).Value
sumRow.Cells(“custQtY”).Value = sum
NextImported from legacy forums. Posted by fullstop (had 371 views)
First, I don’t see where you add the summary row to the group in the GridControl Begin/EndInit block.
i.e. : group.FooterRows.Add(sRow);
Second, I recommend that you try to add a group and then a Summary row to that group in the designer. This will create many lines of code. Analyze those line, and you will see how to properly set up a summary row within a group.
Basically, you need to add the summary row to the group, and set up the summary cell as needed. Here is code generated from the designer in C# :
private Xceed.Grid.SummaryRow summaryRow1;
private Xceed.Grid.SummaryCell cellsummaryRow1OrderID;
private Xceed.Grid.SummaryCell cellsummaryRow1ProductID;
private Xceed.Grid.SummaryCell cellsummaryRow1UnitPrice;
private Xceed.Grid.SummaryCell cellsummaryRow1Quantity;
private Xceed.Grid.SummaryCell cellsummaryRow1Discount;this.summaryRow1 = new Xceed.Grid.SummaryRow();
this.cellsummaryRow1OrderID = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1ProductID = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1UnitPrice = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1Quantity = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1Discount = new Xceed.Grid.SummaryCell();this.group1.FooterRows.Add(this.summaryRow1);
//only to show what is the group to which it is added
this.group1.GroupBy = “ProductID”;
this.group1.HeaderRows.Add(this.groupManagerRow1);// summaryRow1
//
this.summaryRow1.Cells.Add(this.cellsummaryRow1OrderID);
this.summaryRow1.Cells.Add(this.cellsummaryRow1ProductID);
this.summaryRow1.Cells.Add(this.cellsummaryRow1UnitPrice);
this.summaryRow1.Cells.Add(this.cellsummaryRow1Quantity);
this.summaryRow1.Cells.Add(this.cellsummaryRow1Discount);
this.summaryRow1.TextFormat = “UnitPrice : %AVG: UnitPrice format=\”0.##\”%”;
this.summaryRow1.CellValueChanged += new System.EventHandler(this.summaryRow1_CellValueChanged);
//
// cellsummaryRow1OrderID
//
this.cellsummaryRow1OrderID.FormatSpecifier = “0.0000”;
this.cellsummaryRow1OrderID.ResultDataType = typeof(long);
this.cellsummaryRow1OrderID.Click += new System.EventHandler(this.cellsummaryRow1OrderID_Click);
this.cellsummaryRow1OrderID.Initialize(“OrderID”);
//
// cellsummaryRow1ProductID
//
this.cellsummaryRow1ProductID.ResultDataType = typeof(long);
this.cellsummaryRow1ProductID.Initialize(“ProductID”);
//
// cellsummaryRow1UnitPrice
//
this.cellsummaryRow1UnitPrice.TitleFormat = “52”;
this.cellsummaryRow1UnitPrice.TitlePosition = Xceed.Grid.TitlePosition.PreferablyRight;
this.cellsummaryRow1UnitPrice.Visible = true;
this.cellsummaryRow1UnitPrice.Initialize(“UnitPrice”);
//
// cellsummaryRow1Quantity
//
this.cellsummaryRow1Quantity.TitleFormat = “”;
this.cellsummaryRow1Quantity.Initialize(“Quantity”);
//
// cellsummaryRow1Discount
//
this.cellsummaryRow1Discount.FormatSpecifier = “0.##”;
this.cellsummaryRow1Discount.ResultDataType = typeof(System.Double);
this.cellsummaryRow1Discount.StatFunction = Xceed.Grid.StatFunction.Average;
this.cellsummaryRow1Discount.TitleFormat = “Discount”;
this.cellsummaryRow1Discount.Initialize(“Discount”);Imported from legacy forums. Posted by André (had 4125 views)
-
AuthorPosts
- You must be logged in to reply to this topic.