Group Summaries:
I dont know if anyone has suggested it yet or even if it is possible to do it right now, but I would like the user to be able to right-click on the columns group summary and select from a context menu what he/she would like to see (Sum,Min,Max,Average, etc) for that column.
I've attacked an example of what i'm trying to describe.
Column Group Views:
I would also like to suggest an ability to use the column chooser and to drag an entire group from the grid to the column chooser window, this would allow the user to quickly add/remove entire groups from the gridview.
If any of this is currently possible, i would really like to know how I can achieve any of these.
Thank You.
I dont know if anyone has suggested it yet or even if it is possible to do it right now, but I would like the user to be able to right-click on the columns group summary and select from a context menu what he/she would like to see (Sum,Min,Max,Average, etc) for that column.
I've attacked an example of what i'm trying to describe.
Column Group Views:
I would also like to suggest an ability to use the column chooser and to drag an entire group from the grid to the column chooser window, this would allow the user to quickly add/remove entire groups from the gridview.
If any of this is currently possible, i would really like to know how I can achieve any of these.
Thank You.
5 Answers, 1 is accepted
0
Accepted

Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 12:03 AM
Hello Ryan,
I've done the first one for you. Apologies this code is a bit messy, but it does work. Plenty of improvements to be made but I'm sure you get the general idea.
It's just a RadGridView on a form. Please let me know if you have any questions, and may I ask you to mark as answer if this suggestion helps.
If this works well for you, I'll try and get it done properly as a Code Library project as I think this would be really useful and it was an excellent suggestion.
Best regards,
Richard
I've done the first one for you. Apologies this code is a bit messy, but it does work. Plenty of improvements to be made but I'm sure you get the general idea.
It's just a RadGridView on a form. Please let me know if you have any questions, and may I ask you to mark as answer if this suggestion helps.
If this works well for you, I'll try and get it done properly as a Code Library project as I think this would be really useful and it was an excellent suggestion.
Imports
Telerik.WinControls.UI
Imports
Telerik.WinControls
Imports
System.ComponentModel
Imports
System.Reflection
Public
Class
Form1
Private
m_Summary
As
GridViewSummaryItem
Private
m_SummaryRowItem
As
GridViewSummaryRowItem
Private
m_AggregateFunction
As
AggregateFunction
Private
m_ContextMenu
As
New
RadDropDownMenu()
Private
Enum
AggregateFunction
<Description(
"The average is: "
)> _
Avg
<Description(
"The count is: "
)> _
Count
<Description(
"The max is: "
)> _
Max
<Description(
"The min is: "
)> _
Min
' Any others that you want
End
Enum
Private
Shared
Function
AggregateFunctionToGridAggregateFunction(
ByVal
aggregateFunction
As
AggregateFunction)
As
GridAggregateFunction
Select
aggregateFunction
Case
aggregateFunction.Avg
Return
GridAggregateFunction.Avg
Case
aggregateFunction.Count
Return
GridAggregateFunction.Count
Case
aggregateFunction.Max
Return
GridAggregateFunction.Max
Case
aggregateFunction.Min
Return
GridAggregateFunction.Min
End
Select
End
Function
Private
Shared
Function
GetEnumDescription(
ByVal
en
As
[
Enum
])
As
String
Dim
type
As
Type = en.[
GetType
]()
Dim
memInfo
As
MemberInfo() = type.GetMember(en.ToString())
If
memInfo IsNot
Nothing
AndAlso
memInfo.Length > 0
Then
Dim
attrs
As
Object
() = memInfo(0).GetCustomAttributes(
GetType
(DescriptionAttribute),
False
)
If
attrs IsNot
Nothing
AndAlso
attrs.Length > 0
Then
Return
DirectCast
(attrs(0), DescriptionAttribute).Description
End
If
End
If
Return
en.ToString()
End
Function
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
Me
.RadGridView1.AllowAddNewRow =
False
Me
.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
Me
.RadGridView1.Columns.Add(
New
GridViewTextBoxColumn(
"Month"
))
Me
.RadGridView1.Columns.Add(
New
GridViewDecimalColumn(
"Income"
))
Dim
rowInfo
As
GridViewRowInfo =
Me
.RadGridView1.Rows.AddNew()
rowInfo.Cells(0).Value =
"January"
rowInfo.Cells(1).Value = 22.5
rowInfo =
Me
.RadGridView1.Rows.AddNew()
rowInfo.Cells(0).Value =
"February"
rowInfo.Cells(1).Value = 30.65
rowInfo =
Me
.RadGridView1.Rows.AddNew()
rowInfo.Cells(0).Value =
"March"
rowInfo.Cells(1).Value = 4.65
rowInfo =
Me
.RadGridView1.Rows.AddNew()
rowInfo.Cells(0).Value =
"April"
rowInfo.Cells(1).Value = 21.57
rowInfo =
Me
.RadGridView1.Rows.AddNew()
rowInfo.Cells(0).Value =
"May"
rowInfo.Cells(1).Value = 24.65
Me
.m_AggregateFunction = AggregateFunction.Avg
Dim
summarytext
As
String
= GetEnumDescription(AggregateFunction.Avg)
m_Summary =
New
GridViewSummaryItem(
"Income"
, summarytext &
" {0}"
, GridAggregateFunction.Avg)
m_SummaryRowItem =
New
GridViewSummaryRowItem()
m_SummaryRowItem.Add(m_Summary)
Me
.RadGridView1.MasterTemplate.SummaryRowsBottom.Add(m_SummaryRowItem)
For
Each
func
In
[
Enum
].GetValues(
GetType
(AggregateFunction))
Dim
menuItem
As
New
RadMenuItem(func.ToString())
m_ContextMenu.Items.Add(menuItem)
AddHandler
menuItem.Click,
AddressOf
MenuItem_Click
menuItem.CheckOnClick =
True
If
String
.Equals(m_AggregateFunction.ToString(), func.ToString())
Then
menuItem.IsChecked =
True
End
If
Next
End
Sub
Private
Sub
RadGridView1_ContextMenuOpening(
ByVal
sender
As
System.
Object
,
ByVal
e
As
Telerik.WinControls.UI.ContextMenuOpeningEventArgs)
Handles
RadGridView1.ContextMenuOpening
If
TypeOf
e.ContextMenuProvider
Is
GridSummaryCellElement
Then
e.ContextMenu = m_ContextMenu
End
If
End
Sub
Private
Sub
MenuItem_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
menuItem
As
RadMenuItem =
DirectCast
(sender, RadMenuItem)
Dim
summarytext
As
String
=
""
Dim
useThisFunction
As
AggregateFunction
For
Each
func
In
[
Enum
].GetValues(
GetType
(AggregateFunction))
If
String
.Equals(func.ToString(), menuItem.Text)
Then
Me
.m_AggregateFunction =
CType
(func, AggregateFunction)
summarytext = GetEnumDescription(
CType
(func, AggregateFunction))
useThisFunction =
CType
(func, AggregateFunction)
End
If
Next
For
Each
menu
As
RadMenuItem
In
Me
.m_ContextMenu.Items
If
Not
String
.Equals(menu.Text, menuItem.Text)
Then
menu.IsChecked =
False
End
If
Next
Me
.RadGridView1.SummaryRowsBottom.Clear()
m_Summary =
New
GridViewSummaryItem(
"Income"
, summarytext &
" {0}"
, AggregateFunctionToGridAggregateFunction(useThisFunction))
m_SummaryRowItem =
New
GridViewSummaryRowItem()
m_SummaryRowItem.Add(m_Summary)
Me
.RadGridView1.MasterTemplate.SummaryRowsBottom.Add(m_SummaryRowItem)
End
Sub
End
Class
Best regards,
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 12:10 AM
Adding screenshot
0

Ryan
Top achievements
Rank 1
answered on 26 Nov 2010, 09:25 PM
Thanks alot Richard, that is exactly what I was looking for.
Much Appreciated!
Much Appreciated!
0

Richard Slade
Top achievements
Rank 2
answered on 27 Nov 2010, 11:01 AM
Hi Ryan,
You're welcome. I've vamped it up a bit since and it now handles datatime columns too. It's now just an inherited RadGridView. I'll submit it to the Code Library so hope it should be up there soon.
Regards,
Richard
You're welcome. I've vamped it up a bit since and it now handles datatime columns too. It's now just an inherited RadGridView. I'll submit it to the Code Library so hope it should be up there soon.
Regards,
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 30 Nov 2010, 09:58 AM
Hi Ryan,
I thought you'd be interested to know that the Code Library now lists this new article with a better version of what you had above.
it can be found here
hope that's helpful.
Richard
I thought you'd be interested to know that the Code Library now lists this new article with a better version of what you had above.
it can be found here
hope that's helpful.
Richard