User (Old forums)MemberNovember 18, 2005 at 8:48 pmPost count: 23064
I created a master / detail grid with MS SQL, and the Northwind database, i am populating the master and detail grid with the Orders and Order detail tables, and everything is super.
i have one problem though, i am trying to put a summary row, (ValueRow) at the bottom of each detail grid, i want to sum the quantity field only, how do i do that with the least amount of code?
Can someone please show me a very simple code sample how to do this?
I thought this would be as easy as selecting a column in the detail grid and setting a summary property to Sum, or Count, or AVG, or Max / Min etc… HELP !
Imported from legacy forums. Posted by Artmic (had 3904 views)User (Old forums)MemberNovember 19, 2005 at 2:47 amPost count: 23064
Ok I got it to work with a ValueRow and TextRow, too bad the sample directory didn’t have anything as simple as this to show a person coming from the Delphi world.
It is a bit daunting to go through 2000 lines of code in a sample project, picking only parts that you need for a simple sum of a column in a detail grid.
The following code works for me, and is put inside the valueRow SiblingDataRowsChanged event. [The “Quantity” field below has to be replaced to fit your table in use.]
private void valueRow1_SiblingDataRowsChanged(object sender, System.EventArgs e)
ValueRow mySummaryRow = ( ValueRow )sender;
System.Int16 total = 0;
foreach( Xceed.Grid.DataRow row in mySummaryRow.ParentGroup.GetSortedDataRows( false ) )
total += ( System.Int16 )row.Cells[ “Quantity” ].Value;
mySummaryRow.Cells[“Quantity”].Value = total.ToString();
Imported from legacy forums. Posted by Artmic (had 347 views)Xceed SupportMemberNovember 21, 2005 at 9:38 amPost count: 5658
The GridExtensions sample has a class called SummaryRow (also SummaryCell) which shows how to derive to create a SummaryRow.
With the next release of Xceed Grid for .NET, a SummaryRow is included which will automatically calculate a variety of statistical functions.
Imported from legacy forums. Posted by Jenny [Xceed] (had 362 views)User (Old forums)MemberNovember 21, 2005 at 9:59 amPost count: 23064
Thanks for the reply,
that would be awsome to have,
like a little property to set, and the column is auto-calculated for sum, avg, max, min or something. 😀
Imported from legacy forums. Posted by Artmic (had 460 views)Xceed SupportMemberNovember 21, 2005 at 11:30 amPost count: 5658
That (and some other features) is basically how it works 🙂
You add the SummaryRow, set the StatFunction property of the desired SummaryCell in the row and voilà!
Imported from legacy forums. Posted by Jenny [Xceed] (had 258 views)User (Old forums)MemberNovember 21, 2005 at 12:12 pmPost count: 23064
Yes, that world be ideal for simple summation of a qty column or price column, for things like that simplicity is perfect 🙂
Although it is good to have the ability to also do your own “special” calculations too lol
Well i spent the weekend playing with some of the components, and i’m going to tell the boss to buy it. I love the components so far,
Imported from legacy forums. Posted by Artmic (had 5082 views)
- You must be logged in to reply to this topic.